hoodiehq / hoodie

:dog: The Offline First JavaScript Backend
Apache License 2.0
4.4k stars 462 forks source link

Feature: Create docs to suggest users to use monitor and watcher tools. #696

Open Manosmer opened 7 years ago

Manosmer commented 7 years ago

I have an idea to implement pm2 as a start/stop/monitor server service, with a watcher activated in order to achieve an auto-restart function of the server every time a change is made in somebody's project. In that way we can save our users from the frustrating process of closing and reopening the server every time they add something new.

gr2m commented 7 years ago

I don’t know about pm2. Would that be something that would be incorporated in Hoodie’s codebase or something we could add to the documentation as a tip for people working on Hoodie apps?

Manosmer commented 7 years ago

pm2 is an independant module that can deamonize processes (make them run on the background) and it provides basic monitoring and file watching. For example if you want to run server.js (which is a file that implements a basic expressjs server) then, instead of node server.js, you can give the command pm2 start --name="My Server" --watch server.js -- [parameters that server.js file requires separated with '--']. What will follow is that pm2 will run server on the background with a process id and the name of "My Server". Also, it will watch the files of the project to locate changes and restart the server automatically. At last, with the command pm2 monit, a batch file is being executed and percetages of CPU and main memory usage are shown in the command line interface, for every process the pm2 has started.

mbad0la commented 7 years ago

@gr2m @Litarhis

IMHO using pm2 would be somewhat an overkill because pm2 is used for running node apps in the production

In that way we can save our users from the frustrating process of closing and reopening the server every time they add something new.

If I'm not mistaken, the user here is the developer hence my concerns about using a production tool. What we could do here is go for nodemon or something similar.

gr2m commented 7 years ago

@Litarhis sounds like a super cool tool! I agree with @mbad0la that it might be a bit overkill, but it sounds interesting nevertheless? Maybe worth to write a blog post on it?

If it’s a tool used in production, maybe we could amend our deployment docs?

mbad0la commented 7 years ago

If it’s a tool used in production, maybe we could amend our deployment docs?

Any docs related to deployment would benefit from this, so this is a good addition.

As for local setups, I guess we should probably leave it to the developer. A blog post would come in handy in such a scenario.

Manosmer commented 7 years ago

@gr2m @mbad0la, I think you are both right. It's better to leave it to the preferences of the user (a.k.a. developer). It's better if we can create a doc about suggesting our users to use a watcher and how to do so.