0

I am using PM2 to keep Ghost (blogging platform) alive and I need a Cron Job to restart Ghost in the event of a server reboot. However, I am unsure of the proper code for the Cron Job.

I read that this is what I am to use:

@reboot /usr/local/bin/npm start /path/to/ghost/

but instead of using npm start should I replace it with pm2 start index.js which is what I use to start Ghost with PM2?

Note: I do not have root access and I cannot use pm2 startup. This is why I am using a Cron Job. Also this area is new to me; please provide examples.

4

1 回答 1

2

是的,我会将 pm2 命令放入 cron 作业中。要确保 pm2 在正确的环境中启动您的 Ghost 博客,请运行以下命令:

echo "export NODE_ENV=production" >> ~/.profile

这是您希望在 cron 作业中使用 pm2 启动 Ghost 的命令:

cd /path/to/ghost; pm2 start index.js --name ghost

您可以在此处查看我在 pm2 上的文章以获取更多详细信息和选项。

于 2014-03-18T14:38:39.560 回答