From 82809ae929f6e5da261c603af7b2375286ccc525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Macias?= Date: Wed, 17 Feb 2021 16:56:08 +0100 Subject: [PATCH] [systemd] Allow to configure service name suffix --- README.md | 1 + lib/capistrano/php_fpm/php_fpm.rake | 1 + lib/capistrano/php_fpm/tasks/systemd.rake | 10 +++++----- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index dcd30a7..261afc4 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/lib/capistrano/php_fpm/php_fpm.rake b/lib/capistrano/php_fpm/php_fpm.rake index 2c164e9..982224e 100644 --- a/lib/capistrano/php_fpm/php_fpm.rake +++ b/lib/capistrano/php_fpm/php_fpm.rake @@ -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 \ No newline at end of file diff --git a/lib/capistrano/php_fpm/tasks/systemd.rake b/lib/capistrano/php_fpm/tasks/systemd.rake index 439cc2b..4b0092c 100644 --- a/lib/capistrano/php_fpm/tasks/systemd.rake +++ b/lib/capistrano/php_fpm/tasks/systemd.rake @@ -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