Skip to content

Commit 4d1d681

Browse files
authored
Merge pull request #2 from jeromemacias/master
[systemd] Allow to configure service name suffix
2 parents 110e931 + 82809ae commit 4d1d681

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Configurable options shown here are also the defaults:
5656
set :php_fpm_with_sudo, true
5757
set :php_fpm_roles, :web
5858
set :php_fpm_service_name, 'php-fpm' # Change this if you have non-standard naming for the php-fpm service
59+
set :php_fpm_service_suffix, '.service' # Only used for systemd environment, change this if your service name is not sufixed by this
5960
set :systemctl_location, '/bin/systemctl' # May already exist if you use other plugins. Be sure to check your config/deploy/{env} file
6061
```
6162

lib/capistrano/php_fpm/php_fpm.rake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ namespace :load do
33
set :php_fpm_with_sudo, true
44
set :php_fpm_roles, :web
55
set :php_fpm_service_name, 'php-fpm'
6+
set :php_fpm_service_suffix, '.service'
67
set :systemctl_location, '/bin/systemctl'
78
end
89
end

lib/capistrano/php_fpm/tasks/systemd.rake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,35 @@ namespace :'php_fpm' do
22
desc 'Reload php_fpm'
33
task :reload do
44
on release_roles(fetch(:php_fpm_roles)) do
5-
fetch(:php_fpm_with_sudo) ? execute(:sudo, fetch(:systemctl_location), "reload #{fetch(:php_fpm_service_name)}.service") : execute(fetch(:systemctl_location), "reload #{fetch(:php_fpm_service_name)}.service")
5+
fetch(:php_fpm_with_sudo) ? execute(:sudo, fetch(:systemctl_location), "reload #{fetch(:php_fpm_service_name)}#{fetch(:php_fpm_service_suffix)}") : execute(fetch(:systemctl_location), "reload #{fetch(:php_fpm_service_name)}#{fetch(:php_fpm_service_suffix)}")
66
end
77
end
88

99
desc 'Zap php_fpm'
1010
task :zap do
1111
on release_roles(fetch(:php_fpm_roles)) do
12-
fetch(:php_fpm_with_sudo) ? execute(:sudo, fetch(:systemctl_location), "zap #{fetch(:php_fpm_service_name)}.service") : execute(fetch(:systemctl_location), "zap #{fetch(:php_fpm_service_name)}.service")
12+
fetch(:php_fpm_with_sudo) ? execute(:sudo, fetch(:systemctl_location), "zap #{fetch(:php_fpm_service_name)}#{fetch(:php_fpm_service_suffix)}") : execute(fetch(:systemctl_location), "zap #{fetch(:php_fpm_service_name)}#{fetch(:php_fpm_service_suffix)}")
1313
end
1414
end
1515

1616
desc 'Stop php_fpm'
1717
task :stop do
1818
on release_roles(fetch(:php_fpm_roles)) do
19-
fetch(:php_fpm_with_sudo) ? execute(:sudo, fetch(:systemctl_location), "stop #{fetch(:php_fpm_service_name)}.service") : execute(fetch(:systemctl_location), "stop #{fetch(:php_fpm_service_name)}.service")
19+
fetch(:php_fpm_with_sudo) ? execute(:sudo, fetch(:systemctl_location), "stop #{fetch(:php_fpm_service_name)}#{fetch(:php_fpm_service_suffix)}") : execute(fetch(:systemctl_location), "stop #{fetch(:php_fpm_service_name)}#{fetch(:php_fpm_service_suffix)}")
2020
end
2121
end
2222

2323
desc 'Start php_fpm'
2424
task :start do
2525
on release_roles(fetch(:php_fpm_roles)) do
26-
fetch(:php_fpm_with_sudo) ? execute(:sudo, fetch(:systemctl_location), "start #{fetch(:php_fpm_service_name)}.service") : execute(fetch(:systemctl_location), "start #{fetch(:php_fpm_service_name)}.service")
26+
fetch(:php_fpm_with_sudo) ? execute(:sudo, fetch(:systemctl_location), "start #{fetch(:php_fpm_service_name)}#{fetch(:php_fpm_service_suffix)}") : execute(fetch(:systemctl_location), "start #{fetch(:php_fpm_service_name)}#{fetch(:php_fpm_service_suffix)}")
2727
end
2828
end
2929

3030
desc 'Restart php_fpm'
3131
task :restart do
3232
on release_roles(fetch(:php_fpm_roles)) do
33-
fetch(:php_fpm_with_sudo) ? execute(:sudo, fetch(:systemctl_location), "restart #{fetch(:php_fpm_service_name)}.service") : execute(fetch(:systemctl_location), "restart #{fetch(:php_fpm_service_name)}.service")
33+
fetch(:php_fpm_with_sudo) ? execute(:sudo, fetch(:systemctl_location), "restart #{fetch(:php_fpm_service_name)}#{fetch(:php_fpm_service_suffix)}") : execute(fetch(:systemctl_location), "restart #{fetch(:php_fpm_service_name)}#{fetch(:php_fpm_service_suffix)}")
3434
end
3535
end
3636
end

0 commit comments

Comments
 (0)