Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use systemctl [start|stop|restart] when foreman_format is set to systemd #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 32 additions & 12 deletions lib/mina/foreman/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
set :foreman_sudo, true
set :foreman_format, 'upstart'
set :foreman_location, '/etc/init'
set :foreman_service, -> {
case fetch(:foreman_format)
when 'systemd'
"#{fetch(:foreman_app)}.target"
else
fetch(:foreman_app)
end
}
set :foreman_procfile, 'Procfile'

namespace :foreman do
Expand All @@ -20,25 +28,37 @@

desc "Start the application services"
task :start do
command %{
echo "-----> Starting #{fetch(:foreman_app)} services"
#{echo_cmd %[sudo start #{fetch(:foreman_app)}]}
}
command %{echo "-----> Starting #{fetch(:foreman_app)} services"}

command echo_cmd case fetch(:foreman_format)
when 'systemd'
%[sudo systemctl start #{fetch(:foreman_service)}]
else
%[sudo start #{fetch(:foreman_service)}]
end
end

desc "Stop the application services"
task :stop do
command %{
echo "-----> Stopping #{fetch(:foreman_app)} services"
#{echo_cmd %[sudo stop #{fetch(:foreman_app)}]}
}
command %{echo "-----> Stopping #{fetch(:foreman_app)} services"}

command echo_cmd case fetch(:foreman_format)
when 'systemd'
%[sudo systemctl stop #{fetch(:foreman_service)}]
else
%[sudo stop #{fetch(:foreman_service)}]
end
end

desc "Restart the application services"
task :restart do
command %{
echo "-----> Restarting #{fetch(:foreman_app)} services"
#{echo_cmd %[sudo start #{fetch(:foreman_app)} || sudo restart #{fetch(:foreman_app)}]}
}
command %{echo "-----> Restarting #{fetch(:foreman_app)} services"}

command echo_cmd case fetch(:foreman_format)
when 'systemd'
%[sudo systemctl restart #{fetch(:foreman_service)}]
else
%[sudo start #{fetch(:foreman_service)} || sudo restart #{fetch(:foreman_service)}]
end
end
end