By skeddtemp
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:
rm ./data/mongod.lock 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.
Questions:
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)?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.