Created
July 28, 2016 06:49
-
-
Save ainoya/ea1f4079ab0b7b0011747324a8729fde to your computer and use it in GitHub Desktop.
damonize process and restart regularly
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
#!/usr/bin/env ruby | |
require 'rufus-scheduler' | |
$stdout.sync = true | |
scheduler = Rufus::Scheduler.new | |
def exec_command(cmd) | |
IO.popen(cmd) do |io| | |
while (line = io.gets) do | |
puts line | |
end | |
end | |
end | |
def deploy_process | |
puts `git pull` | |
puts `pip2 install -r requirements.txt` | |
puts `pkill -f hogescript.py` | |
exec_command "python2 hogescript.py" | |
end | |
scheduler.in '1s' do | |
deploy_process | |
end | |
scheduler.every '30m' do | |
deploy_process | |
end | |
scheduler.join |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment