Created
December 10, 2013 15:34
-
-
Save seyhunak/7892544 to your computer and use it in GitHub Desktop.
Managing Long Running Background Scripts On Ubuntu Using Supervisor For Rails Application
This file contains 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
1. Installing | |
apt-get install supervisor | |
service supervisor restart | |
2. Setting shell script | |
nano /usr/local/bin/rake.sh | |
#!/bin/bash | |
# Starting rake script | |
cd /home/ubuntu/www/introduce_biz && RAILS_ENV=production bundle exec rake venue:parse --silent | |
# Started rake script | |
3. Setting Permissions | |
chmod +x /usr/local/bin/rake.sh | |
4. Creating script configuration | |
/etc/supervisor/conf.d/rake.conf | |
[program:rake] | |
command=/usr/local/bin/rake.sh | |
autostart=true | |
autorestart=true | |
stderr_logfile=/var/log/rake.err.log | |
stdout_logfile=/var/log/rake.out.log | |
5. Tell Supervisor to initialize your script | |
supervisorctl reread | |
supervisorctl update | |
6. Tailing output | |
tail -f /var/log/rake.out.log | |
Managing Scripts | |
1. supervisorctl | |
supervisor> stop rake | |
supervisor> start rake | |
supervisor> restart rake | |
supervisor> tail rake # for stdout | |
supervisor> tail rake stderr # for stderr | |
supervisor> status | |
supervisor> quit! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you please add
rake venue:parse --silent
task also?