In the console/terminal for an app, run ps -ux | grep server
:
app@tree-jelly:~ 11:48
$ ps -ux | grep server
app 1573 0.3 0.1 1128360 46804 ? Sl 11:46 0:00 node server.js
app 1644 0.0 0.0 12944 932 pts/0 S+ 11:48 0:00 grep server
Then, back in Glitch add a file to the project named myfile.html
, and then run ps -ux | grep server
again:
app@tree-jelly:~ 11:48
$ ps -ux | grep server
app 1573 0.2 0.1 1128616 47296 ? Sl 11:46 0:00 node server.js
app 1646 0.0 0.0 12944 976 pts/0 S+ 11:50 0:00 grep server
Okay, it’s the same PID for node server.js
. Which is good.
Now, back in Glitch add a file to the project named myfile.js
, and then run ps -ux | grep server
a third time:
app@tree-jelly:~ 11:50
$ ps -ux | grep server
app 1667 6.3 0.1 1062584 45944 ? Sl 11:51 0:00 node server.js
app 1705 0.0 0.0 12944 936 pts/0 S+ 11:51 0:00 grep server
You will see that the PID for node server.js
has changed. Which is bad.
This is a problem for me because in the node server.js
process is where I have a custom chokidar watcher running, and it gets restarted when a .js
file changes (or is added) before it gets a chance to kick off its build. I’m hoping I don’t have to implement any hacks to work around this, because I like having my watcher be part of server.js
so that it gets integrated seamlessly with all the other auto stuff that Glitch does.
Is there a solution to my problem though, whether hack-y or not?
One peculiar observation is that I actually only observe this process restarting behavior for a brand new Glitch. If I walk away for >5 mins and come back after the app container has had a chance to shut down, then start it back up it again, then this process restarting problem magically goes away?
Anyone have any insight into this behavior I’m observing, or more importantly have a fix?
I need a fix because this is part of a workflow for people that will be new to Glitch. I will be having them import from GitHub and don’t want part of that tutorial process to be “walk away from the computer for 5 minutes before trying to edit any JavaScript files”.
I have tested this many times with new vanilla and import projects and it is consistently a reproducible problem.