Comments (14)
A standard unix way of doing such things would be something like that:
pm2 start script.js -- -d 1
when anything after "--" parameter is passed to the script
(see http://unix.stackexchange.com/questions/11376/what-does-double-dash-mean)
PS: I suppose, commander
can already do that, just add something like process.argv = commander.argv
after a require.
from pm2.
NOTICE that the arguments you supply will persist until you delete and restart the app:
pm2 start app.js -- aa bb cc
pm2 restart app.js -- 11 22 33
Above will not work, you should do the following:
pm2 delete app.js
pm2 start app.js -- 11 22 33
However I think it's weird, what if I want to change an argument...
from pm2.
Now with PM2 > 1.1.x
this:
$ pm2 start app.js -- aa bb cc
$ pm2 restart app.js -- 11 22 33
works, but doing
$ pm2 restart app.js
Will still keep the latest arguments (11, 22, 33)
from pm2.
Now with PM2 > 1.1.x
this:
$ pm2 start app.js -- aa bb cc
$ pm2 restart app.js -- 11 22 33
works, but doing$ pm2 restart app.js
Will still keep the latest arguments (11, 22, 33)
Hello. I dont need to keep latest arguments. How can i "nullify" them?
from pm2.
Not sure we can do that easily for now, as require is used for launching the script.
The alternative would be to use environment variables instead.
CLI Code :
https://github.com/Unitech/pm2/blob/master/bin/pm2#L235
Fork child ProcessContainer.js :
http://nodejs.org/api/cluster.html#cluster_cluster_fork_env
ProcessContainer script require :
https://github.com/Unitech/pm2/blob/master/lib/ProcessContainer.js#L56
from pm2.
I think it would be really easy to parse extra params within single quote chars and enrich process.argv with them.
On 19 jun. 2013, at 05:49, Alexandre Strzelewicz [email protected] wrote:
Not sure we can do that easily for now, as require is used for launching the script.
The alternative would be to use environment variables instead.CLI Code :
https://github.com/Unitech/pm2/blob/master/bin/pm2#L235Fork child ProcessContainer.js :
http://nodejs.org/api/cluster.html#cluster_cluster_fork_envProcessContainer script require :
https://github.com/Unitech/pm2/blob/master/lib/ProcessContainer.js#L56—
Reply to this email directly or view it on GitHub.
from pm2.
That's a solution, pull me a request 👍 ! :)
from pm2.
Not behind comp today nor have time soon, but will do at some point...
On 19 jun. 2013, at 12:54, Alexandre Strzelewicz [email protected] wrote:
That's a solution, pull me a request ! :)
—
Reply to this email directly or view it on GitHub.
from pm2.
Nice. Learned a thing on my day off ;)
On 19 jun. 2013, at 18:43, Alex Kocharin [email protected] wrote:
A standard unix way of doing such things would be something like that:
pm2 start script.js -- -d 1when anything after "--" parameter is passed to the script
(see http://unix.stackexchange.com/questions/11376/what-does-double-dash-mean)
—
Reply to this email directly or view it on GitHub.
from pm2.
Fixed and thanks for the tip Alex ;)
from pm2.
@xieranmaya Thank you!
from pm2.
@Unitech Great improve!
from pm2.
Is there a way to run two processes with different arguments but the same script with this configuration?
It also seems that i cant put more than 8 arguments in there:
pm2 start log --name "Logger" --node-args='--harmony_destructuring' -- arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8
[PM2] Starting log in fork_mode (1 instance)
[PM2] Done.
pm2 start log --name "Logger" --node-args='--harmony_destructuring' -- arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9
[PM2][ERROR] script not found : /somedir/bin/arg9
from pm2.
What is the way to run
pm2 start --env production --node-args "DB_HOST=some.host.xyz DB_NAME=mybase DB_USER=heman DB_PASSWORD=Morning@r00t90"
from pm2.
Related Issues (20)
- Try catch blocks cause the pm2 app to crash when an exception is caught. HOT 2
- pm2 logs do not print realtime on M2 Pro HOT 1
- use pm2 start index.ts occur Error HOT 1
- Question regarding logging :question: HOT 1
- Critical error on compatibility with pm2 on automatically start service on system startup cases HOT 1
- Sudden PM2 core dump. Asking for assistance in finding the root cause, if possible. HOT 2
- `pm2 logs` with a namespace doesn't work if run before relevant `pm2 start`
- PM2 and cluster mode in Node.js/TypeScript HOT 5
- ***Urgent***: GNU-AGPL License Concerns HOT 1
- https://id.keymetrics.io/api/oauth/register not loading HOT 1
- Slow and crush HOT 2
- Suddenly crased HOT 2
- Pm2 start a new daemon and delete all my apps HOT 2
- Load balancing is not distribute the load evenly
- Graviton3 support – intermittent crash/coredump HOT 1
- Configuration file management app log confusion issues.
- PM2 start with next.js is too slow
- Replace/remove/fix vizion dependency causing annoying popups flashing in Windows
- Pm2 God Daemon crashes and does not properly recover
- Logs more than 2 years before are included into current daily logs with huge sizes HOT 1
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.