Skip to content

Instantly share code, notes, and snippets.

@mpapis
Forked from anonymous/output
Last active December 26, 2015 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpapis/7206121 to your computer and use it in GitHub Desktop.
Save mpapis/7206121 to your computer and use it in GitHub Desktop.
nick ALL=NOPASSWD:/sbin/start foo,/sbin/stop foo,/sbin restart foo,/sbin/service foo start,/sbin/service foo stop,/sbin/service foo restart,/home/nick/.rvm/wrappers/foo/foreman
desc "Restart application"
task :restart do
on roles(:app) do
execute :rvm, "alias create #{fetch(:application)} #{fetch(:rvm_ruby_version)}"
execute :rvm, "wrapper #{fetch(:application)} --no-links bundle"
#invoke "foreman:export" # <-- this does not work in cap v3
execute "sudo /home/nick/.rvm/wrappers/my_app/bundle exec foreman export upstart /etc/init -e #{fetch(:rails_env)} -a #{fetch(:application)} -u #{fetch(:user)} -l /var/#{fetch(:application)}/log"
# on OS X the equivalent pid-finding command is `ps | grep '/puma' | head -n 1 | awk {'print $1'}`
execute "(kill -s SIGUSR1 $(ps -C ruby -F | grep '/puma' | awk {'print $2'})) || sudo service #{fetch(:application)} restart"
# foreman.restart # uncomment this (and comment line above) if we need to read changes to the procfile
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment