How to make an application run continuously in Node.js, including strapi
Rus
Eng
Как на Node.js заставить приложение работать постоянно, в том числе strapi

All English-language materials have been translated fully automatically using the Google service

Developing projects on strapi for a long time I could not figure out how to make the application work on the server all the time. Including thought that you need to keep the SSH console running. Everything turned out to be much easier. It is enough to install and use one of two applications: forever or pm2

pm2

pm2 is a Node.js process manager with built-in load balancer

Installation

  npm install pm2 -g  

Launch Application

  pm2 start app.js  

Running the application as a process

  pm2 start ./bin/www --name = "app"  

List of running applications

  pm2 list  

Stop application

  pm2 stop 0  

Stop all

  pm2 stop all  

Restart all

  pm2 restart all  

Journal

  pm2 logs ['all' | app_name | app_id]  

You can try one of the following commands to run strapi

  pm2 start /home/bitrix/ext_www/example.ru/site --name = "npm run develop"
NODE_ENV = development pm2 start strapi --no-pmx --name = "site" - start
NODE_ENV = development pm2 start strapi --no-pmx --name = site - start  

Forever

Installation

  npm install -g forever  

Launch Application

  forever app.js  

Running the application as a service

  forever start app.js  

Limit the number of application restarts. For example in case of failure

  forever -m7 app.js  

List of running applications

  forever list  

Stop the process, where the number in brackets is the process id from the forever list

command
  forever stop 1  

Restart application

  forever restart 1  

Restart application on any file change

  forever -w app.js  

To run strapi you can try the command

  forever start -c "npm start" /home/bitrix/ext_www/example.ru/site  

Comments

There are no comments yet, you can be the first to leave it

Leave a comment

The site uses a comment pre-moderation system, so your message will be published only after approval by the moderator

You are replying to a user's comment

Send

FEEDBACK

Email me

Are you developing a new service, making improvements to the existing one and want to be better than your competitors? You have come to the right place. I offer you a comprehensive studio-level website development. From me you can order design, layout, programming, development of non-traditional functionality, implementation of communication between CMS, CRM and Data Analitics, as well as everything else related to sites, except for promotion.

Contact, I will always advise on all questions and help you find the most effective solution for your business. I am engaged in the creation of sites in Novosibirsk and in other regions of Russia, I also work with the CIS countries. You will be satisfied with our cooperation

An error occurred while sending, please try again after a while
Message sent successfully

Phones

+7(993) 007-18-96

Email

info@tichiy.ru

Address

Россия, г. Москва

By submitting the form, you automatically confirm that you have read and accept the Privacy Policy site

Contact with me
Send message
By submitting the form, you automatically confirm that you have read and accept Privacy policy of site
Sending successful!
Thank you for contacting :) I will contact you as soon as possible
Sending failed
An error occurred while sending the request. Please wait and try again after a while or call my phone number