thywill
Version:
A Node.js clustered framework for single page web applications based on asynchronous messaging.
58 lines (52 loc) • 2.23 kB
Plain Text
#!upstart
#
# An example upstart script for running a Thywill application 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 "Thywill"
start on startup
stop on shutdown
# Needed to track the pid of the Node process started by Forever.
expect fork
# The following environment variables must be set. Below are example settings
# for the Echo application, if Node.js was installed from source into
# /home/node/local/node as described in /doc/serverSetup.md.
#
# Your settings will depend on where Node.js, Thywill, and the application
# start and shutdown preparation scripts are located.
#
# The full path to the directory containing the node and forever binaries.
# env NODE_BIN_DIR="/home/node/local/node/bin"
# Set the NODE_PATH to the Node.js main node_modules directory.
# env NODE_PATH="/home/node/local/node/lib/node_modules"
# The directory containing the application start Javascript file.
# env APPLICATION_DIRECTORY="/home/node/thywill/applications/echo/service"
# The application start Javascript filename.
# env APPLICATION_START="startEcho.js"
# Log file path.
# env LOG="/var/log/thywill-echo.log"
env NODE_BIN_DIR=""
env NODE_PATH=""
env APPLICATION_DIRECTORY=""
env APPLICATION_START=""
env LOG=""
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.
exec forever --sourceDir $APPLICATION_DIRECTORY -a -l $LOG --minUptime 5000 --spinSleepTime 2000 start $APPLICATION_START
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.
exec forever stop $APPLICATION_DIRECTORY/$APPLICATION_START >> $LOG
end script