Files
NodeBB/nodebb

137 lines
3.1 KiB
Plaintext
Raw Normal View History

2013-12-06 11:27:34 -05:00
#!/bin/bash
# $0 script path
# $1 action
# $2 subaction
node="$(which nodejs 2>/dev/null)";
if [ $? -gt 0 ];
then node="$(which node)";
fi
2014-03-17 13:20:07 -04:00
function pidExists() {
if [ -e "pidfile" ];
then
2014-11-17 14:47:36 -05:00
if ps -p $(cat pidfile) > /dev/null
2014-03-17 13:20:07 -04:00
then return 1;
2014-11-17 14:47:36 -05:00
else
rm ./pidfile;
return 0;
2014-03-17 13:20:07 -04:00
fi
else
return 0;
fi
}
2013-12-06 11:27:34 -05:00
case "$1" in
start)
echo "Starting NodeBB";
echo " \"./nodebb stop\" to stop the NodeBB server";
echo " \"./nodebb log\" to view server output";
# Start the loader daemon
"$node" loader "$@"
;;
stop)
pidExists;
if [ 0 -eq $? ];
then
echo "NodeBB is already stopped.";
else
echo "Stopping NodeBB. Goodbye!";
kill $(cat pidfile);
fi
;;
restart)
pidExists;
if [ 0 -eq $? ];
then
echo "NodeBB could not be restarted, as a running instance could not be found.";
else
echo "Restarting NodeBB.";
kill -1 $(cat pidfile);
fi
2014-03-17 13:20:07 -04:00
;;
reload)
pidExists;
if [ 0 -eq $? ];
then
echo "NodeBB could not be reloaded, as a running instance could not be found.";
else
echo "Reloading NodeBB.";
kill -12 $(cat pidfile);
fi
;;
2014-03-17 13:20:07 -04:00
status)
pidExists;
if [ 0 -eq $? ];
then
echo "NodeBB is not running";
echo " \"./nodebb start\" to launch the NodeBB server";
else
echo "NodeBB Running (pid $(cat pidfile))";
echo " \"./nodebb stop\" to stop the NodeBB server";
echo " \"./nodebb log\" to view server output";
echo " \"./nodebb restart\" to restart NodeBB";
fi
;;
log)
clear;
tail -F ./logs/output.log;
2013-12-06 11:27:34 -05:00
;;
upgrade)
npm install
# ls -d node_modules/nodebb* | xargs -n1 basename | xargs npm install
# ls -d node_modules/nodebb* | xargs -n1 basename | xargs npm update
2014-05-31 01:58:26 -04:00
npm i nodebb-theme-vanilla nodebb-theme-lavender nodebb-widget-essentials
"$node" app --upgrade
2014-02-13 12:26:43 -05:00
touch package.json
;;
2014-02-13 13:10:40 -05:00
setup)
"$node" app --setup "$@"
2014-02-13 13:10:40 -05:00
;;
reset)
"$node" app --reset --$2
;;
2014-02-18 22:46:44 +00:00
2013-12-06 11:27:34 -05:00
dev)
echo "Launching NodeBB in \"development\" mode."
echo "To run the production build of NodeBB, please use \"forever\"."
2014-07-24 18:36:41 -04:00
echo "More Information: https://docs.nodebb.org/en/latest/running/index.html"
NODE_ENV=development "$node" loader --no-daemon "$@"
2013-12-06 11:27:34 -05:00
;;
watch)
echo "Launching NodeBB in \"development\" mode."
echo "To run the production build of NodeBB, please use \"forever\"."
2014-07-24 18:36:41 -04:00
echo "More Information: https://docs.nodebb.org/en/latest/running/index.html"
NODE_ENV=development supervisor -q --ignore public/templates,public/nodebb.min.js,public/nodebb.min.js.map --extensions 'node|js|tpl|less' -- app "$@"
2013-12-06 11:27:34 -05:00
;;
*)
echo "Welcome to NodeBB"
2014-02-27 23:24:52 -05:00
echo $"Usage: $0 {start|stop|reload|restart|log|setup|reset|upgrade|dev|watch}"
2013-12-06 11:27:34 -05:00
echo ''
column -s ' ' -t <<< '
2014-02-27 10:13:36 -05:00
start Start the NodeBB server
stop Stops the NodeBB server
reload Restarts NodeBB
restart Restarts NodeBB
2014-02-27 10:13:36 -05:00
log Opens the logging interface (useful for debugging)
2014-02-27 10:30:09 -05:00
setup Runs the NodeBB setup script
reset Disables all plugins, restores the default theme.
2014-01-06 19:24:09 -05:00
upgrade Run NodeBB upgrade scripts, ensure packages are up-to-date
2014-02-27 10:13:36 -05:00
dev Start NodeBB in interactive development mode
watch Start NodeBB in development mode and watch for changes
2013-12-06 11:27:34 -05:00
'
exit 1
esac