Use supervisor instead of systemd or upstart
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
[program:yellowent]
|
||||
command=node app.js
|
||||
directory=/opt/box
|
||||
@@ -1,73 +0,0 @@
|
||||
#!upstart
|
||||
#
|
||||
# An example upstart script for running a Node.js process as a service
|
||||
# using Forever as the process monitor. For more configuration options
|
||||
# associated with Forever, see: https://github.com/nodejitsu/forever
|
||||
#
|
||||
# You will need to set the environment variables noted below to conform to
|
||||
# your use case, and should change the description.
|
||||
#
|
||||
description "Yellowtent upstart script"
|
||||
|
||||
start on startup
|
||||
stop on shutdown
|
||||
|
||||
# This line is needed so that Upstart reports the pid of the Node.js process
|
||||
# started by Forever rather than Forever's pid.
|
||||
expect fork
|
||||
|
||||
# The following environment variables must be set so as to define where Node.js
|
||||
# and Forever binaries and the Node.js source code can be found.
|
||||
#
|
||||
# The example environment variables below assume that Node.js is installed by
|
||||
# building from source with the standard settings.
|
||||
#
|
||||
# It should be easy enough to adapt to the paths to be appropriate to a package
|
||||
# installation, but note that the packages available in the default repositories
|
||||
# are far behind the times. Most users will be building from source to get a
|
||||
# more recent Node.js version.
|
||||
#
|
||||
# The full path to the directory containing the node and forever binaries.
|
||||
# env NODE_BIN_DIR="/usr/local/bin"
|
||||
# Set the NODE_PATH to the Node.js main node_modules directory.
|
||||
# env NODE_PATH="/usr/local/lib/node_modules"
|
||||
# The application startup Javascript file path.
|
||||
# env APPLICATION_PATH="/home/node/my-application/start-my-application.js"
|
||||
# Process ID file path.
|
||||
# PIDFILE=/var/run/my-application.pid
|
||||
# Log file path.
|
||||
# env LOG="/var/log/my-application.log"
|
||||
# Forever settings to prevent the application spinning if it fails on launch.
|
||||
# env MIN_UPTIME="5000"
|
||||
# env SPIN_SLEEP_TIME="2000"
|
||||
|
||||
env NODE_BIN_DIR="/usr/bin"
|
||||
env NODE_PATH="/usr/lib/node_modules"
|
||||
env APPLICATION_PATH="/opt/box/app.js"
|
||||
env LOG="/var/log/yellowtent.log"
|
||||
env MIN_UPTIME="5000"
|
||||
env SPIN_SLEEP_TIME="2000"
|
||||
|
||||
script
|
||||
# Add the node executables to the path, which includes Forever if it is
|
||||
# installed globally, which it should be.
|
||||
PATH=$NODE_BIN_DIR:$PATH
|
||||
# The minUptime and spinSleepTime settings stop Forever from thrashing if
|
||||
# the application fails immediately on launch. This is generally necessary
|
||||
# to avoid loading development servers to the point of failure every time
|
||||
# someone makes an error in application initialization code, or bringing
|
||||
# down production servers the same way if a database or other critical
|
||||
# service suddenly becomes inaccessible.
|
||||
exec forever -l $LOG start $APPLICATION_PATH
|
||||
end script
|
||||
|
||||
pre-stop script
|
||||
# Add the node executables to the path.
|
||||
PATH=$NODE_BIN_DIR:$PATH
|
||||
# Here we're using the pre-stop script to stop the Node.js application
|
||||
# process so that Forever is given a chance to do its thing and tidy up
|
||||
# its data. Note that doing it this way means that each application that
|
||||
# runs under Forever must have a different start file name, regardless of
|
||||
# which directory it is in.
|
||||
exec forever stop $APPLICATION_PATH
|
||||
end script
|
||||
@@ -1,13 +0,0 @@
|
||||
[Service]
|
||||
ExecStart=/usr/bin/node /usr/bin/yellowtent
|
||||
Restart=always
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog
|
||||
SyslogIdentifier=yellowtent
|
||||
User=yellowtent
|
||||
Group=yellowtent
|
||||
Environment=NODE_ENV=production
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
Reference in New Issue
Block a user