node. JS deployed to the server after the daemon manager forever

Source: Internet
Author: User
Tags node server

It is not possible to manage remote sites directly through the node command, which does not guarantee the sustainable operation of the site. We use forever to solve this problem, it can be nodejs to apply the way the future daemon, we can also set the Nodejs app to run automatically with the system boot.

First, install Forever:

NPM Install FOREVER-GD

So the forever is installed, we can run the Forever command directly:

Forever--helpforever start app.jsforever stop app.js

The above command first looks at the forever Help file, then runs App.js, and then stops app.js. We want to let forever run automatically, first create a file node in the/ETC/INIT.D directory, the contents are as follows:

#!/bin/bash## node Start up node server daemon## chkconfig:345 85 15# Description:forever forNode.js#path=/home/node/0.8.9/Bindeamon=/home/ftp/1520/weizt-20120918-tkx/weizt.com/App.jslog=/home/Hosts_logpid=/tmp/Forever.pid Case"$"inchstart) forever start-L $LOG/forever.log-o $LOG/forever_out.log-e $LOG/forever_err.log--pidfile $PID-a $DEAMONstop) Forever Stop--pidfile $PID $DEAMON stopall) Forever StopAll--pidfile $PID Restartall) Forever Restartall--pidfile $PID Reload|restart) Forever Restart-L $LOG/forever.log-o $LOG/forever_out.log-e $LOG/forever_err.log--pidfile $PID-a $DEAMONlist) Forever list*) echo"Usage:/etc.init.d/node {start|stop|restart|reload|stopall|restartall|list}"Exit1Esacexit0

The above code is my local virtual machine configuration, according to the actual situation to modify the relevant parameters, mainly Deamon path parameters, give the file executable permissions, and run Chkconfig add Autorun:

chmod 755/etc/init.d/nodechkconfig/etc/init.d/node on

Reboot restart system, through the browser to enter the site can be found, the NODEJS has been able to run automatically, the rest of the work is to study Nodejs, Express and Angularjs, do a really own application!

node. JS deployed to the server after the daemon manager forever

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.