cmd = {
:start => "nohup npm start juggernaut &",
:ps => "ps aux | grep npm"
}
while true
result = `#{cmd[:ps]}`.split("\n").select { |line| line unless line =~ /grep/ }
if result.size < 1
puts "restart juggernaut"
system("#{cmd[:start]}")
else
puts "ok"
end
sleep 5
end
ruby xxx.rb