Join 1M+ other developers and:
- Get help and share knowledge in Q&A
- Subscribe to topics of interest
- Get courses & tools that help you grow as a developer or small business owner
Can PM2 run scripts? Can you specify what order
I want to use PM2 so that my server is restarted if it crashes.
My server uses mongo and node. When I want to start the server on c9 after it’s been stopped, I first run a script mongo-start.sh which does the following:
mongod –nojournal –dbpath=data –repair
mongod –nojournal –dbpath=data
I had to clear the lock at the beginning because it seemed to get locked every time it shut down, which is very frequently with c9.
Then once that is running I run my server with bin/www and the node runner.
Can I just tell PM2 to run the mongo script? Or does it have to be an application?
How can I make sure it doesn’t try to run the web server first? If it’s run before mongo, it crashes?
If you can’t run scripts, is there a way to use options on the command you want to run, such as –dbpath=data on mongo? It seems to interpret it as a pm2 option (which doesnt exist)?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×