Ubuntu Server Run JS, let JS run down

Source: Internet
Author: User

SSH connection Ubuntu,node xxx.js run JS, a close SSH connection, JS service is closed. Baidu has discovered a great God's answer here copy a big God answer, to record

let Ghost always run the previous mentioned start Ghost using the NPM Start command. This is a good choice to start and test in development mode, but there is a downside to booting with this command line: Ghost stops when you close the terminal window or disconnect from SSH. In order to prevent Ghost from stopping working, there are two ways to solve this problem. Forever (https://npmjs.org/package/forever)you can use forever to run Ghost in a background task. Forever will follow Ghost's configuration and restart Ghost when the process crash. Via NPM Install Forever-g Install forever in order for forever to run from the Ghost installation directory, enter Node_env=production forever start Index.js stop ghost by Forever stop Index.js list to check if Ghost is currently running forever (supervisor c0>//supervisord.org/)popular Linux distributions-such as Fedora, Debian, and Ubuntu-contain a Supervisor package: a Process Control system that allows you to run Ghost without initializing the script at boot time. Unlike initialization scripts, Supervisor can be ported to different distributions and versions. Install Supervisor According to the different Linux distributions. As shown below: Debian/ubuntu:apt-GetInstall Supervisorfedora:yum Install supervisor Most other distributions: Easy_install Supervisor through service supervisor start to ensure Super Visor run to create a startup script for Ghost. is usually/etc/supervisor/conf.d/ghost.conf, for example: [Program:ghost]command= node/path/to/ghost/index.jsdirectory=/path/to/Ghostuser=Ghostautostart=trueAutoRestart=trueStdout_logfile= /var/log/supervisor/Ghost.logstderr_logfile= /var/log/supervisor/ghost_err.logenvironment= node_env="Production"use Supervisor to start Ghost:supervisorctl start ghost Stop Ghost:supervisorctl stop Ghost For more information, see the Supervisor documentation. 

Excerpt from
http://docs.ghostchina.com/zh/installation/deploy/

Ubuntu Server Run JS, let JS run down

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.