Skip to content

Commit

Permalink
Merge pull request #2 from jeromemacias/master
Browse files Browse the repository at this point in the history
[systemd] Allow to configure service name suffix
  • Loading branch information
soullivaneuh authored Mar 13, 2023
2 parents 110e931 + 82809ae commit 4d1d681
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Configurable options shown here are also the defaults:
set :php_fpm_with_sudo, true
set :php_fpm_roles, :web
set :php_fpm_service_name, 'php-fpm' # Change this if you have non-standard naming for the php-fpm service
set :php_fpm_service_suffix, '.service' # Only used for systemd environment, change this if your service name is not sufixed by this
set :systemctl_location, '/bin/systemctl' # May already exist if you use other plugins. Be sure to check your config/deploy/{env} file
```

Expand Down
1 change: 1 addition & 0 deletions lib/capistrano/php_fpm/php_fpm.rake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace :load do
set :php_fpm_with_sudo, true
set :php_fpm_roles, :web
set :php_fpm_service_name, 'php-fpm'
set :php_fpm_service_suffix, '.service'
set :systemctl_location, '/bin/systemctl'
end
end
10 changes: 5 additions & 5 deletions lib/capistrano/php_fpm/tasks/systemd.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@ namespace :'php_fpm' do
desc 'Reload php_fpm'
task :reload do
on release_roles(fetch(:php_fpm_roles)) do
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")
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)}")
end
end

desc 'Zap php_fpm'
task :zap do
on release_roles(fetch(:php_fpm_roles)) do
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")
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)}")
end
end

desc 'Stop php_fpm'
task :stop do
on release_roles(fetch(:php_fpm_roles)) do
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")
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)}")
end
end

desc 'Start php_fpm'
task :start do
on release_roles(fetch(:php_fpm_roles)) do
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")
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)}")
end
end

desc 'Restart php_fpm'
task :restart do
on release_roles(fetch(:php_fpm_roles)) do
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")
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)}")
end
end
end
Expand Down

0 comments on commit 4d1d681

Please sign in to comment.