Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Sep 16th, 2012  |  syntax: None  |  size: 0.69 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # Install Upstart
  2. sudo apt-get install -y upstart
  3.  
  4. cat > /etc/init/nodeServer.conf << EOF
  5. #!upstart
  6. description "node.js server"
  7. author      "jsermeno"
  8.  
  9. start on startup
  10. stop on shutdown
  11.  
  12. script
  13.     export HOME="/root"
  14.    
  15.     NODE_ENV=production node /root/www/app.js 2>&1 >> /var/log/node.log
  16. end script
  17. EOF
  18.  
  19. chmod +x /etc/init/nodeServer.conf
  20.  
  21. # Install Monit
  22. sudo apt-get install -y monit
  23.  
  24. cat > /etc/monit/monitrc << EOF
  25. #!monit
  26. set logfile /var/log/monit.log
  27.  
  28. check host nodejs with address 127.0.0.1
  29.     start program = "/sbin/start nodeServer"
  30.     stop program  = "/sbin/stop nodeServer"
  31.     if failed port 3000 protocol HTTP
  32.         request /
  33.         with timeout 10 seconds
  34.         then restart
  35. EOF