1

I just put my node application up on my ubuntu server. I successfully started the program using

nodejs index.js

Now it gives me the "listening on *:3000"

The problem is that I am ssh'd into my ubuntu server, but the cursor is stuck under the "listening" line.

1) How can I close my ssh session and leave the node running? Should I have started the node with a different user?

2) Once I successfully close my ssh session and the node is still running. How can I stop node once I ssh back into the server?

3) Say I ssh into the server and start run my nodejs file, but I then want to do some other simple work for unrelated sites on the same server. Since the cursor is stuck after "listening" line, how can I go about doing anything else?

Gilberg
  • 2,514
  • 4
  • 31
  • 41
  • 2
    This is what you'll want to use: https://help.ubuntu.com/community/Screen Alternatively, you can run your command as a service. Look into UpStart. – Scheda Jun 10 '15 at 20:44

1 Answers1

0

I suggest that you use the screen program. Screen is a terminal multiplexer, which allows a user to access multiple separate terminal sessions inside a single terminal window or remote terminal session (such as when using SSH).

It can be started by typing screen on a terminal. Inside it, you can call node.js as usual. Then you press Ctrl+a and type d to detach it. To re-attach a detached session type screen -r.

More information can be found on the manual

Hbas
  • 904
  • 6
  • 21