-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--cron not seemingly working #496
Comments
Yes, I don't see why someone would need it if he has an actual cron (other than for b/w compatibility). That said, @stockholmux 's error is just about escaping strings in bash command line. This should work better (didn't test though): $ pm2 start wpServices.node.js -n wpService --cron '36 8 * * *' |
@rlidwka thanks for the update. I'll try that. Just to chime in on the need of this - it's nice to be able to do everything with PM2 for deployment instead of having to setup the pm2 start then edit the crontab file. It took a minute to figure out the directories for using crontab. It's not really that straight forward:
If I had a vote, I'd keep it, maybe just document a bit better. |
I'm with @stockholmux on this one. I love having cron_restart on the JSON config file. |
Yes cron-like timing is very useful. I currently have 10 processes that I run for local development at work, together with a few maintenance tasks. Having everything in one JSON file is great! |
Hey, just to add to this, I've noticed that having a config where:
Having autorestart false disables the cron restart. I want to be able to exit the process gracefully after the script runs. My work around is to close all the db connections and sockets after the script runs but do not exit it. I feel like this is an issue with the cron_restart. |
@michaelBenin any update on this??
My config file is this :
but cron_restart doesnt work. |
What version of pm2? This issue is not new. |
pm2 --version It seems to working with js file.(cluster_mode) |
Currently |
but according to https://github.com/Unitech/pm2/blob/master/CHANGELOG.md#0147 |
I changed my script
So that it should end gracefully , just for testing purpose. But no luck. Its not working |
Actually no, the change was that its the process container that ask to pm2 to be killed (see https://github.com/Unitech/pm2/blob/master/lib/ProcessContainerFork.js#L20) |
@michaelBenin Any updates? I have the same problem with |
Any updates? Is there a PM2 way to run Is PM2 cron_restart intended to "ease" deployment configs and "replace" crontab for PM2 apps? We need more docs on it. |
I built this file and am sharing just to help other devs. This will consider you listed your routines as apps with Run the microservice using the The builder will automatically consider PM2 path from NVM default alias and your project root path. Just need to edit * * * * *, "PM2_ENVS" AND "ROUTINES_NAMES" for your expectations. #!/bin/sh
# RUN THIS FILE INSIDE YOUR PROJECT ROOT ON THE FINAL ENVIRONMENT HOST
PM2_ENVS=('development' 'staging' 'production')
ROUTINES_NAMES=('pm2-app-a', 'pm2-app-b')
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
PROJ_DIR="$SCRIPTPATH"
NODE_VERSION=$(cat ~/.nvm/alias/default)
NODE_NVM="~/.nvm/versions/node/v$NODE_VERSION"
NODE="$NODE_NVM/bin/node"
PM2="$NODE_NVM/lib/node_modules/pm2/bin/pm2"
for PM2_ENV in "${PM2_ENVS[@]}"
do
echo "# PM2 ENVIRONMENT=$PM2_ENV"
for ROUTINE_NAME in "${ROUTINES_NAMES[@]}"
do
echo "* * * * * $NODE $PM2 restart '$PROJ_DIR/ecosystem.config.js' --env '$PM2_ENV' --only '$ROUTINE_NAME'"
done
done |
I can't seem to get pm2's cron to actually restart a process - take this example:
(other process were redacted)
Am I doing something wrong or is this an actual bug?
The text was updated successfully, but these errors were encountered: