Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js forever module - get path to a script that is running?

When a script is running with the forever module and you "forever list", you get a list with the filenames of all currently running scripts. In this case, "myscript1.js"

[0] j2mo /usr/local/bin/node myscript1.js 51004   51005 /Users/me/.forever/j2mo.log 0:14:10:51.420 
[1] Vav3 /usr/local/bin/node myscript1.js 51011   51012 /Users/me/.forever/Vav3.log 0:14:10:21.221 

Is there a way to get also the path to all running scripts?

like image 702
Nikolay Dyankov Avatar asked Oct 10 '13 09:10

Nikolay Dyankov


People also ask

How do I get the path to the current script with node js?

We can get the path of the present script in node. js by using __dirname and __filename module scope variables. __dirname: It returns the directory name of the current module in which the current script is located. __filename: It returns the file name of the current module.

What is NPM forever?

What is forever? Forever is an npm module that ensures a Node. js script continuously runs in the background on the server. It's a helpful CLI tool for the production environment because it helps manage the Node applications and their processes.

How do I find the path of a node?

Node can tell you where in the file system it is working by using the _filename and _dirname variables. The _filename variable provides the absolute path to the file that is currently executing; _dirname provides the absolute path to the working directory where the file being executed is located.


1 Answers

Use this to add directory column in the output

forever columns add dir
like image 194
ankush Avatar answered Oct 21 '22 07:10

ankush