diff --git a/README.md b/README.md index a822693..5521cea 100644 --- a/README.md +++ b/README.md @@ -26,12 +26,14 @@ Require one of the above 'Environments Supported' in your `Capfile`: require 'capistrano/apache/systemd' ``` -`capistrano/apache` comes with 5 tasks: +`capistrano/apache` comes with 7 tasks: * apache:reload * apache:force_reload * apache:restart +* apache:graceful * apache:stop +* apache:graceful_stop You can execute the task on command line: diff --git a/lib/capistrano/apache/tasks/systemd.rake b/lib/capistrano/apache/tasks/systemd.rake index 404cb58..9ac6b12 100644 --- a/lib/capistrano/apache/tasks/systemd.rake +++ b/lib/capistrano/apache/tasks/systemd.rake @@ -20,6 +20,13 @@ namespace :apache do end end + desc 'Gracefuly stop apache (requires root access to apache stop)' + task :graceful_stop do + on release_roles(fetch(:apache_roles)) do + fetch(:apache_with_sudo) ? execute(:sudo, fetch(:systemctl_location), "graceful-stop #{fetch(:apache_service_name)}.service") : execute(fetch(:systemctl_location), "graceful-stop #{fetch(:apache_service_name)}.service") + end + end + desc 'Start apache (requires root access to apache start)' task :start do on release_roles(fetch(:apache_roles)) do @@ -33,6 +40,13 @@ namespace :apache do fetch(:apache_with_sudo) ? execute(:sudo, fetch(:systemctl_location), "restart #{fetch(:apache_service_name)}.service") : execute(fetch(:systemctl_location), "restart #{fetch(:apache_service_name)}.service") end end + + desc 'Gracefuly restart apache (requires root access to apache restart)' + task :graceful do + on release_roles(fetch(:apache_roles)) do + fetch(:apache_with_sudo) ? execute(:sudo, fetch(:systemctl_location), "graceful #{fetch(:apache_service_name)}.service") : execute(fetch(:systemctl_location), "graceful #{fetch(:apache_service_name)}.service") + end + end end diff --git a/lib/capistrano/apache/tasks/sysv_upstart.rake b/lib/capistrano/apache/tasks/sysv_upstart.rake index 4266171..66adb97 100644 --- a/lib/capistrano/apache/tasks/sysv_upstart.rake +++ b/lib/capistrano/apache/tasks/sysv_upstart.rake @@ -20,6 +20,13 @@ namespace :apache do end end + desc 'Gracefuly stop apache' + task :graceful_stop do + on release_roles(fetch(:apache_roles)) do + fetch(:apache_with_sudo) ? execute(:sudo, "/etc/init.d/#{fetch(:apache_service_name)}", 'graceful-stop') : execute("/etc/init.d/#{fetch(:apache_service_name)}", 'graceful-stop') + end + end + desc 'Start apache' task :start do on release_roles(fetch(:apache_roles)) do @@ -33,4 +40,11 @@ namespace :apache do fetch(:apache_with_sudo) ? execute(:sudo, "/etc/init.d/#{fetch(:apache_service_name)}", 'restart') : execute("/etc/init.d/#{fetch(:apache_service_name)}", 'restart') end end + + desc 'Gracefuly restart apache' + task :graceful do + on release_roles(fetch(:apache_roles)) do + fetch(:apache_with_sudo) ? execute(:sudo, "/etc/init.d/#{fetch(:apache_service_name)}", 'graceful') : execute("/etc/init.d/#{fetch(:apache_service_name)}", 'graceful') + end + end end \ No newline at end of file