As I said in the previous blog Puppet module to setup nodejs deployment, the nodejs module was for providing the basic infrastructure for automated node app's deployment & as promised I've released the next module "nodeapp" that can be used to setup a node app on the target server.
First of all I'll talk about what this module will do to facilitate the automated deployment of a nodejs app, as already discussed we are following a convention that all the node app's code will be present at /home/nodejs/ which is referred by startNodeApp.sh script so we create the directory of nodejs app. The deployNodeApp.sh script was using the upstart to manage the nodejs app instance i.e starting/stoppping the nodejs app, the nodeapp module takes care of creating the require upstart configuration at /etc/init/.conf . Also we use monit to monitor the nodejs app's so that we can start/stop the nodejs app's using the web ui of monit & also see various stats such as cpu, memory, load.. consumption of nodejs app.
This nodeapp module is a userdefined type which takes the name of nodeapp as an argument, as a result of which you can setup any number of nodejs app's on a system.
i.e nodeapp{'search-demo': app_name => "search-demo"}
This entry will create below files
/etc/init/search-demo.conf : An upstart configuration file, using which search demo nodejs app can be managed as a service.
First of all I'll talk about what this module will do to facilitate the automated deployment of a nodejs app, as already discussed we are following a convention that all the node app's code will be present at /home/nodejs/
This nodeapp module is a userdefined type which takes the name of nodeapp as an argument, as a result of which you can setup any number of nodejs app's on a system.
i.e nodeapp{'search-demo': app_name => "search-demo"}
This entry will create below files
/etc/init/search-demo.conf : An upstart configuration file, using which search demo nodejs app can be managed as a service.
#!upstart
description "node.js search-demo server"
author "sandy"
start on startup
stop on shutdown
script
export HOME="/home/nodejs"
echo $$ > /var/run/search-demo.pid
exec sudo -u nodejs /home/nodejs/startNodeApp.sh search-demo
end script
pre-start script
# Date format same as (new Date()).toISOString() for consistency
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /var/log/search-demo.sys.log
end script
pre-stop script
rm /var/run/search-demo.pid
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /var/log/search-demo.sys.log
end script
/etc/monit/conf.d/search-demo.monit : A monit configuration file, using which search-demo nodejs app can be monitored & even automatedly restarted
check process search-demo with pidfile /var/run/search-demo.pid
stop program = "/sbin/stop search-demo"
start program = "/sbin/start search-demo"
So using these 2 modules nodejs & nodeapp you can make any system up & running for nodejs app's automated deployment
description "node.js search-demo server"
author "sandy"
start on startup
stop on shutdown
script
export HOME="/home/nodejs"
echo $$ > /var/run/search-demo.pid
exec sudo -u nodejs /home/nodejs/startNodeApp.sh search-demo
end script
pre-start script
# Date format same as (new Date()).toISOString() for consistency
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /var/log/search-demo.sys.log
end script
pre-stop script
rm /var/run/search-demo.pid
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /var/log/search-demo.sys.log
end script
/etc/monit/conf.d/search-demo.monit : A monit configuration file, using which search-demo nodejs app can be monitored & even automatedly restarted
check process search-demo with pidfile /var/run/search-demo.pid
stop program = "/sbin/stop search-demo"
start program = "/sbin/start search-demo"
So using these 2 modules nodejs & nodeapp you can make any system up & running for nodejs app's automated deployment
No comments:
Post a Comment