Created
July 29, 2017 16:12
-
-
Save avesus/ee6d94349dc915bee1146deacfbabeba to your computer and use it in GitHub Desktop.
Saving RAM on tough servers using daemontools instead of forever.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/node | |
// /var/www/mynodeserver/run | |
require('./index.js'); |
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
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.