Created
May 29, 2014 11:45
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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