Skip to content

Instantly share code, notes, and snippets.

@localhots
Created May 29, 2014 11:45
Show Gist options
  • Select an option

  • Save localhots/c938a0629b1dcf0c4e95 to your computer and use it in GitHub Desktop.

Select an option

Save localhots/c938a0629b1dcf0c4e95 to your computer and use it in GitHub Desktop.
Mina task that saves Unicorn and Sidekiq startup scripts to a file and adds its invocation to crontab on @reboot
namespace :maintenance do
task :save_startup_script do
script = "#!/bin/bash\n"
crontab_task = "@reboot #{deploy_to}/shared/startup.sh > #{deploy_to}/shared/log/startup.log #minareboot"
isolate do
invoke 'unicorn:start'
invoke 'sidekiq:start'
script << commands.join(" && \\\n")
end
queue %| echo "-----> Updating startup script" |
queue! %| echo '#{script}' > #{deploy_to}/shared/startup.sh |
queue! %| chmod +x #{deploy_to}/shared/startup.sh |
queue %| echo "-----> Ensuring @reboot cron task present" |
queue! %| [[ $(crontab -l) != *minareboot* ]] && cat <(crontab -l) <(echo "#{crontab_task}") \| crontab - \|\| true |
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment