Comments (10)
Is this the purpose of the update
CLI command? The docs say that it will "...update the in-memory PM2 daemon..." but I'm not sure if that means it will reread in the latest ecosystem and local files or not. Clarity or perhaps just better documentation on that command would be useful.
from pm2.
@Unitech any thoughts here?
from pm2.
@WillianAgostini is this already possible just not documented well?
from pm2.
Is this the purpose of the
update
CLI command? The docs say that it will "...update the in-memory PM2 daemon..." but I'm not sure if that means it will reread in the latest ecosystem and local files or not. Clarity or perhaps just better documentation on that command would be useful.
This would update the daemon in memory with a newer version if there's any (so let's say, if you did an upgrade of pm2). It shouldn't reread anything. If you want to reread your stored config, you could use pm2 resurrect
. This is not an answer to the OP's question though.
@wmelton for me to understand your issue properly, do you mean to say that when you're using a --cron scheduled restart, an older version of your script is still used? Or is this limited to changes into the ecosystem file?
from pm2.
@ultimate-tester the issue we have is that we have days where we schedule new batch jobs in our ecosystem file in the middle of the day, but do not want our nightly jobs to run as a result of updating it. However, there is no flag/mechanism to tell pm2 to reload/restart our ecosystem file (to see the new job additions/deletions) that does not run all of the jobs right then.
We would want a mechanism to tell pm2 that we have updated our ecosystem file but don't want it to run any scripts within the ecosystem file right then, but instead, wait until the next time the cron constraint is met.
This is a request that isn't new from my google searches, but there appears no way to satisfy this need that I have found in the documentation.
from pm2.
@wmelton thanks for clarifying, I get it now. It's true that right now there's no such feature because of two missing elements:
- The --cron parameter offers a restart strategy (i.e. when to restart) and not a start strategy (i.e. when to start the first time) OR just a parameter to not start initially.
- The command line for PM2 does not offer a way to reload the ecosystem file while maintaining the current state of all applications as they are.
I'd be happy to provide a PR for this, the first item should be easy to reuse the existing cron logic for starting an app instead and the second one would need a bit more fiddling but I'd feel comfortable enough to make this as long as I'm sure the PR will be accepted (to not waste my time/efforts).
from pm2.
@ultimate-tester that would be amazing. I think a start strategy would go a long way in helping us deploy ecosystem changes without restarting all jobs right then when we make changes.
from pm2.
@wmelton alright so I don't have a full setup of pm2 available to me right now to do extensive testing, but I managed to make something out of it. Hopefully it will satisfy your requirements. It can be found at https://github.com/ultimate-tester/pm2/tree/5711.
What this does is introduce an autostart parameter (just like autorestart which already exists). Both to the ecosystem file and as argument to the start command. This means that you can either:
- Add
autostart: false
in your ecosystem file in the app object (apps: [{..., autostart: false,...}]) - Add
--no-autostart
argument to your pm2 start command (e.g.pm2 start app.js --no-autostart
)
Both will result in an app to be added with status stopped.
If I understand your usecase the right way, this means you want to add autostart: false to all your apps that have a cron_restart parameter set. This means that the first start of new apps will be at that cron_restart moment.
Let me know if this works for you and I can request a merge request :)
from pm2.
@ultimate-tester that is exactly what we're looking for 🎉 - Thank you for adding this. Will be awesome to see this merged in to the main trunk.
from pm2.
@ultimate-tester would you be able to open a PR for this? Or is it possible for me to go ahead and open it?
from pm2.
Related Issues (20)
- CVE-2023-42282 | npm `ip` package vulnerable to SSRF or RCE HOT 2
- pm2 is periodically restarting every few seconds without a noticeable error on Google Cloud Run (using Docker)?
- PM2 Start with args (using --) not working on PowerShell HOT 1
- show undefined when i send the invite to user to join
- Better support for dotenv in cluster mode ? HOT 2
- Nodejs app that previously ran fine under pm2 will no longer start, even though same app with same args and user works HOT 5
- Create process but not start HOT 8
- bucket suddenly gone from pm2+ HOT 1
- use cnpm install -g pm2 show error tip
- NextJS 13/14 app router fails with cluster mode with SIGINT HOT 1
- Vulnerability detected in dependent library Braces (CWE-400) HOT 1
- Snyk Package Analysis - Inflight Missing Release of Resource after Effective Lifetime Vulnerability
- migrate to bun HOT 6
- How to use `--wait-ready` for non node-js programs ? HOT 1
- pm2 start (at time) HOT 3
- Interpreter bun not working with multiple instances an cluster HOT 1
- PM2 loses connection with Keymetrics on system reboot HOT 1
- set 'content-length' and 'transfer-encoding:gzip' for 'pm2 serve'
- 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
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.