Created
September 9, 2018 09:54
-
-
Save apwan/c45a075d79d410bacab4874915b486c3 to your computer and use it in GitHub Desktop.
Use start-stop-daemon to launch/exit node app.
This file contains 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/env node | |
//app.js | |
var http = require('http'); | |
server = http.createServer(function(req, res){ | |
res.writeHead(200, {'Content-Type': 'text/html'}); | |
res.write('<h1>Node.js</h1>'); | |
res.end('<p>Hello World</p>'); | |
}).listen(process.env.PORT||4321); | |
console.log("HTTP server is listening at port "+server.address().port); |
This file contains 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/env bash | |
start-stop-daemon --start --quiet --pidfile $1 -m --exec /usr/bin/env -- node app.js > $2 & |
This file contains 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/env bash | |
start-stop-daemon --stop -p $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment