Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can PM2 be used with compiled c programs

Tags:

c

pm2

Is it possible to use pm2 with custom c programs? If so, how is this accomplished? Does it work well? Is you are already using pm2 for node.js apps would it make sense to use it for a c program as well?

like image 577
Timothy Vann Avatar asked Mar 29 '16 16:03

Timothy Vann


People also ask

Can we use pm2 in production?

PM2 features a simple but powerful deployment system that allows to provision and update applications in production environment. This is great when you want to deploy applications on baremetal server in one or many servers at once.

What is difference between pm2 and forever?

forever and PM2 can be primarily classified as "Node. js Process Manager" tools. forever and PM2 are both open source tools. It seems that PM2 with 30K GitHub stars and 2K forks on GitHub has more adoption than forever with 12.5K GitHub stars and 906 GitHub forks.

Does pm2 run forever?

PM2 is a production process manager for Node. js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.


2 Answers

In order to run an precompiled executable file or binary, you need to add "exec_interpreter": "none" and "exec_mode" : "fork_mode" in your JSON file.

{
  "apps" : [{
    "name"       : "binary",
    "script"     : "./binary",
    "exec_interpreter": "none",
    "exec_mode"  : "fork_mode"
  }]
}

Sources: http://pm2.keymetrics.io/docs/usage/process-management/#start-any-process-type and https://github.com/Unitech/pm2/issues/1776#issuecomment-157560622

like image 138
Emilio Avatar answered Oct 01 '22 08:10

Emilio


From testing it is as simple as specifying the executable file. For example to run a c program compiled to a.out use pm2 start a.out.

like image 24
Timothy Vann Avatar answered Oct 01 '22 09:10

Timothy Vann