Node.js process manager is a tool, which provides an ability to control application lifecycle, monitor the running services and facilitate common system admin tasks to maintain your project operability.
CirrusGrid provides four pre-configured process managers by default, which can be selected in the following ways:
by selecting the appropriate tag during the environment creation or container redeploy
by editing the PROCESS_MANAGER Docker environment variable in the already created container(s) with the forever, npm, pm2 or supervisor value (restart is needed to apply the new options)
Below, we’ll consider each of the available managers to help you select one:
A public process manager package is provided for Node.js server within the npm registry. It is a simple module to initiate and configure multiple processes through the spawn method, using a dedicated configuration object with the following parameters:
PM2 provides a huge variety of application management features, including the launched NodeJS processes monitoring. You can get acquainted with the list of commands for pm2, which can be executed directly via SSH.
For example, after Node.js server creation, you can list the running processes with the following command:
As you can see it shows the default draw-game application is running. Next, you can remove this app with the pm2 delete command and deploy your own project (e.g. the default Hello Word by cirrusgrid):
Also, PM2 provides users the ability to create the configuration files where all the run options are listed, which is useful for microservice-based applications deployment, as several apps can be described in a single file. The appropriate config file reference) can be found by following the provided link (e.g. the default ecosystem.config.js file is used to launch the server.js application file as the “draw game” application).
Supervisor is a great solution to keep your applications running. It automatically monitors any code changes in the launched .js scripts and restarts the appropriate app to keep it up-to-date. Herewith, it allows to perform a hot restart of your NodeJS processes, ensuring they are always available and are automatically restarted in the event of a failure.
Note: By default, the supervisor process manager monitors file changes in the application directory and, if any, automatically restarts NodeJS. Herewith, during the VCS deployment (including auto-deploy), your application server will be restarted even if there are no project changes (due to modification of the .git folder).
To avoid the unnecessary restarts, you can disable file changes monitoring by adding the -i parameter into the PROCESS_MANAGER_OPTS variable.
You can run the following command on your Node.js server with the supervisor process manager to get help:
Here, you can find a short description of the module, its usage syntax, additional options descriptions and a few examples.
The forever process manager is the simple CLI tool, which allows to make your NodeJS processes run continuously. It permanently keeps a child process (such as your project on the Node.js web server) and automatically restart it upon failure.
Run the next command to get the main information on the forever manager usage, actions, usage, etc:
Also, using forever you can specify the application options in a JSON file. For example, for the default Draw game (available after Node.js server installation), this /home/jelastic/ROOT/forever.json file looks like:
Powered by BetterDocs
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.