Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can PM2 run command line start scripts?

Tags:

node.js

pm2

I'm using a library, say I want the script that starts my app to be cli-lib start how can i go about that? I don't want to just run node app.js or any js file for that matter, the cli lib does that for me but i cant figure out a way to get this to work.

like image 249
gottimaneee Avatar asked Mar 27 '26 12:03

gottimaneee


2 Answers

Yes you can run any process type with pm2. For scripts in other languages which has assigned an interpreter by default,

pm2 start echo.coffee
pm2 start echo.php
pm2 start echo.py
pm2 start echo.sh
pm2 start echo.rb

or with interpreter

pm2 start echo.pl --interpreter=perl

read more from docs

like image 101
Salitha Avatar answered Apr 02 '26 22:04

Salitha


I think you can create a bash script then run it with pm2, for examples:

bash.sh

#!/usr/bin/bash
node /home/user/test.js

then you can run file "bash.sh" with pm2

pm2 start bash.sh

I did not test it yet but you can try.

like image 36
lamtacvu Avatar answered Apr 02 '26 22:04

lamtacvu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!