Comments (6)
Yes it's normal.
As pm2 wrap code in a "ProcessContainer", the require use the informations of the ProcessContainer.js.
In the process container I've now set require.main.filename to the script you have launched.
It will be available soon
from pm2.
Much obliged, I look forward to trying it out :]
from pm2.
Pushed on Github, can you try and tell me if everything is okay ? :
$ npm install git://github.com/Unitech/pm2.git -g
from pm2.
Hi, I apologise for replying to this so late.
alex@literally:~/docs/code/node$ npm -g ll pm2
│ /usr/lib
│
└── [email protected] (git://github.com/Unitech/pm2.git#9b18ca103eb86048fe7f04f8b4143b9059145045)
The modern CLI process manager for Node apps with native clusterization
git://github.com/Unitech/pm2.git
https://github.com/Unitech/pm2
git://github.com/Unitech/pm2.git
My test file:
console.log(require.main.filename);
using pm2 start test.js
I get the following when viewed with pm2 logs
:
[test out (l2)] /usr/lib/node_modules/pm2/lib/ProcessContainer.js
If you need any more information let me know -- I'll try and respond more speedily in future.
Cheers.
from pm2.
Np,
to resolve the script path with require.main.filename
, you have to set the option MODIFY_REQUIRE
to true https://github.com/Unitech/pm2/blob/master/constants.js#L19
from pm2.
Hi,
How do I set the option MODIFY_REQUIRE=true, setting this as a process env (process.env.MODIFY_REQUIRE=true) did not work as expected.
from pm2.
Related Issues (20)
- When I run pm2 start server.js a virus is detected by BitDefender HOT 1
- Deploy to EC2 in private subnet
- pm2 logs don't update live unless I do "pm2 update" or "pm2 restart" HOT 1
- Exception is not written to ~/.pm2/logs/*.log file from uncaughtException since it's synchronous
- HTTPS Mean Latency missing for two processes
- boot time startup on Ubuntu 24.04 with Wayland, fails HOT 1
- util.isArray is deprecated HOT 3
- Error caught while calling pidusage | PROCESS - Alias not found. HOT 1
- AppData/Roaming/npm/pm2: 15: exec: node: not found
- Pm2 problem related to node v20.13.1 or may be a node v20.13.1 problem
- EPIPE
- CONDENSED_MODE too wide
- Why logs are being created by root?
- How to run pm2 over https ?? HOT 1
- Can't start app when using autostart = false HOT 5
- TypeError: _env[key].slice is not a function when running `pm2 info`
- Cron tasks do not run at system startup until you manually trigger them
- High & Medium Vulnerabilities in two PM2 dependencies
- Services running using pm2 couldnt restart on server reboot
- Feature request: Allow setting `max_restarts` to `false` to disable checking of max restarts
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pm2.