NodeJS API changes not reflected on remote development target

For a target setup:

Remote
Node w/apache proxy
Development
PM2

Changes to Content pages are immediately reflected.

Changes to API’s are not available until I restart the node server.

If I use --watch on PM2, then the API changes trigger a restart, but for Content pages it restarts the server twice (nodemon is doing one, and then PM2 is doing one.)

@patrick @George What is the proper config when using PM2 to manage multiple sites on one server? Is this just a bug on the restart.txt of API files?

You either use nodemon or pm2 but not both.

They just watch the files so there is no restart.txt in that case - they restart automatically on file change.

What type of hosting do you have and how do you upload?

Understood...maybe I made an incorrect assumption that Wappler was using nodemon--I haven't loaded it myself, I only added PM2 (for other reasons, not restart.)

Can I turn off the Wappler restart.txt upload somehow and just rely on PM2? A setting in config.json for example?

My own Centos 8 server uploading via SFTP

Well when uploading NodeJS files with ftp, we assume that is usually using Plesk or cPanel and those run Passenger instead of nodemon or pm2.

Restart.txt is the way passenger forces a restart of its NodeJS server.

Maybe if you are using pm2 you can let it watch just restart.txt and not all files. So it behaves the same.

You don’t want to watch all files anyway because they might be coming one by one through ftp and your NodeJS server will then be restarted 1000 times…

Got it...it helps to know that.

Yep, that works great.

Thanks George.

1 Like