Skip to content

Instantly share code, notes, and snippets.

@avesus
Created July 29, 2017 16:12
Show Gist options
  • Save avesus/ee6d94349dc915bee1146deacfbabeba to your computer and use it in GitHub Desktop.
Save avesus/ee6d94349dc915bee1146deacfbabeba to your computer and use it in GitHub Desktop.
Saving RAM on tough servers using daemontools instead of forever.js
#! /bin/sh
# /etc/init.d/mynodeserver
case "$1" in
start)
supervise /var/www/mynodeserver >> /var/log/mynodeserver.com.nodejs.log 2>/var/log/mynodeserver.com.error.log &
;;
stop)
svc -d /var/www/mynodeserver
svc -x /var/www/mynodeserver
;;
*)
echo "Usage: /etc/init.d/mynodeserver {start|stop}"
exit 1
;;
esac
exit 0
#!/usr/bin/node
// /var/www/mynodeserver/run
require('./index.js');
@avesus
Copy link
Author

avesus commented Jul 29, 2017

See https://untroubled.org/daemontools-encore/svc.8.html on how to control your process monitored by supervise.

See https://untroubled.org/daemontools-encore/supervise.8.html on what supervise does.

@avesus
Copy link
Author

avesus commented Jul 29, 2017

Don't forget to run

$ sudo chmod 755 /etc/init.d/mynodeserver
$ sudo update-rc.d mynodeserver defaults

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment