Code Monkey home page Code Monkey logo

Comments (10)

wmelton avatar wmelton commented on June 19, 2024

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.

wmelton avatar wmelton commented on June 19, 2024

@Unitech any thoughts here?

from pm2.

wmelton avatar wmelton commented on June 19, 2024

@WillianAgostini is this already possible just not documented well?

from pm2.

ultimate-tester avatar ultimate-tester commented on June 19, 2024

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.

wmelton avatar wmelton commented on June 19, 2024

@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.

ultimate-tester avatar ultimate-tester commented on June 19, 2024

@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.

wmelton avatar wmelton commented on June 19, 2024

@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.

ultimate-tester avatar ultimate-tester commented on June 19, 2024

@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.

wmelton avatar wmelton commented on June 19, 2024

@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.

wmelton avatar wmelton commented on June 19, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.