Reputation: 1105
Here is my scenerio, I am developing a nodejs application. I have deployed the application to our server for testing purposes. I am using nodemon to run the app because it's much more easier.
So my problem is, when I am working from home, because of my network problem,I get disconnected from the server frequently.
So, I won't get any logs from the console. What I am doing now is , after each login, I check for nodejs process, Find the processes, kill it and start the app with nodemon again
My question is , is there any way of resuming our nodemon process?
So that we can see the logs right away rather than the approach that I am following now?
Or is this really a very stupid question question?
If there exist any such method, please let me know.
Please help me, I am searching a lot for this , didn't find a solution.
My server is Ubuntu 16 lts
Thanks
Upvotes: 0
Views: 719
Reputation: 2552
There are two options, one thing I personally use (and this will remove your dependency on nodemon) is to use screen
. It's included with most Linux distributions and even if you don't have it installed yet, there's a screen
package in all major Linux distributions.
You create a new screen (for the first time) with screen -S name
and whenever you get disconnected you can easily reattach yourself to the screen with screen -R name
. If you need to detach from your screen you can use Control+A
and Control+D
following each other.
screen
is universal and will work for anything you can do in terminal, it also can be used to create multiple screens if that's needed, just supply a different name argument.
The other solution would be to use tmux
, but it's not as straightforward as screen
.
Creation of a new tmux
session uses the following command tmux new -s name
, then if you need to reattach to a session you will need to use tmux ls
and then find the number of your session there and reattach to it via tmux attach-session -t num
.
Detaching can be done with Control+B
and Control+D
.
Upvotes: 4