Guest User

Untitled

a guest
May 19th, 2014
417
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!upstart
  2. #
  3. # An example upstart script for running a Node.js process as a service
  4. # using Forever as the process monitor. For more configuration options
  5. # associated with Forever, see: https://github.com/nodejitsu/forever
  6. #
  7. # You will need to set the environment variables noted below to conform to
  8. # your use case, and should change the description.
  9. #
  10. description "Example upstart script for a Node.js process"
  11.  
  12. start on startup
  13. stop on shutdown
  14.  
  15. # This line is needed so that Upstart reports the pid of the Node.js process
  16. # started by Forever rather than Forever's pid.
  17. expect fork
  18.  
  19. # The following environment variables must be set so as to define where Node.js
  20. # and Forever binaries and the Node.js source code can be found.
  21. #
  22. # The example environment variables below assume that Node.js is installed by
  23. # building from source with the standard settings.
  24. #
  25. # It should be easy enough to adapt to the paths to be appropriate to a package
  26. # installation, but note that the packages available in the default repositories
  27. # are far behind the times. Most users will be building from source to get a
  28. # more recent Node.js version.
  29. #
  30. # The full path to the directory containing the node and forever binaries.
  31. # env NODE_BIN_DIR="/usr/local/bin"
  32. # Set the NODE_PATH to the Node.js main node_modules directory.
  33. # env NODE_PATH="/usr/local/lib/node_modules"
  34. # The application startup Javascript file path.
  35. # env APPLICATION_PATH="/home/node/my-application/start-my-application.js"
  36. # Process ID file path.
  37. # PIDFILE=/var/run/my-application.pid
  38. # Log file path.
  39. # env LOG="/var/log/my-application.log"
  40. # Forever settings to prevent the application spinning if it fails on launch.
  41. # env MIN_UPTIME="5000"
  42. # env SPIN_SLEEP_TIME="2000"
  43.  
  44. env NODE_BIN_DIR="/usr/bin"
  45. env NODE_PATH="/usr/lib/node_modules"
  46. env APPLICATION_PATH="/home/nodebb/foorum/app.js"
  47. env LOG="/var/log/nodebb.log"
  48. env MIN_UPTIME="5000"
  49. env SPIN_SLEEP_TIME="2000"
  50.  
  51. script
  52. # Add the node executables to the path, which includes Forever if it is
  53. # installed globally, which it should be.
  54. PATH=$NODE_BIN_DIR:$PATH
  55. # The minUptime and spinSleepTime settings stop Forever from thrashing if
  56. # the application fails immediately on launch. This is generally necessary
  57. # to avoid loading development servers to the point of failure every time
  58. # someone makes an error in application initialization code, or bringing
  59. # down production servers the same way if a database or other critical
  60. # service suddenly becomes inaccessible.
  61. exec forever \
  62. --pidFile $PIDFILE \
  63. -a \
  64. -l $LOG \
  65. --minUptime $MIN_UPTIME \
  66. --spinSleepTime $SPIN_SLEEP_TIME \
  67. start $APPLICATION_PATH
  68. end script
  69.  
  70. pre-stop script
  71. # Add the node executables to the path.
  72. PATH=$NODE_BIN_DIR:$PATH
  73. # Here we're using the pre-stop script to stop the Node.js application
  74. # process so that Forever is given a chance to do its thing and tidy up
  75. # its data. Note that doing it this way means that each application that
  76. # runs under Forever must have a different start file name, regardless of
  77. # which directory it is in.
  78. exec forever stop $APPLICATION_PATH
  79. end script
RAW Paste Data