Closing Terminal window terminates SSH
Node won't run unless the terminal window on my computer is open. If i try to close it, it says "Do you want to close this window? Closing this window will terminate the running processes: ssh."
This comes after logging into ssh, then,
If i close the window NodeBB shuts down and i get a gateway error on my website.
I think i saw a thread about this exact problem but now i cant seem to find it.
You'll want to use something like supervisor or forever to keep the process alive after you close the console.
$ sudo npm -g i forever $ forever start app.js
That worked like a charm!
Annd then it crashed and i couldnt get it started. Deleted it. Reinstalled and this came up
xxx@xxx:~# forever start app.js warn: --minUptime not set. Defaulting to: 1000ms warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms info: Forever processing file: app.js error: Cannot start forever error: script /root/app.js does not exist.
Ah, you have to be in the directory your NodeBB is installed in
xxx@xxx:~# cd mynodebb root@motor:~/mynodebb# sudo forever start app.js warn: --minUptime not set. Defaulting to: 1000ms warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms info: Forever processing file: app.js
But it still won't run without the terminal window sitting open like this.
xxx@xxx:~/mynodebb# node app info: NodeBB v0.2.1 Copyright (C) 2013 DesignCreatePlay Inc. info: This program comes with ABSOLUTELY NO WARRANTY. info: This is free software, and you are welcome to redistribute it under certain conditions. info: info: Initializing NodeBB v0.2.1, on port 4567, using redis store at 127.0.0.1:6379. info: NodeBB instance bound to: Any address (0.0.0.0) info: No changes to client-side libraries -- skipping minification info: NodeBB Read
@kevin I'm not exactly sure what you're trying to do. When you run forever start app.js it starts a daemon running in the background. You don't have to run node app again, you can close the terminal, the forever process will take care of your NodeBB.
Also if you're logged in with root (which I'd not encourage) you don't have to use sudo, forever start app.js is fine.
Oh. Thanks. Not typing sudo made it run properly. Wee two things off the list. Now i just need to figure out why it wont stay logged in, or show any of the 'total posts' 'total users' information on the domain. Only if i type in the exact ip and port..
@kevin could you paste your public/config.json content here? Maybe manually configuring the socket.address and socket.port values would help.
@BarveyHirdman I'll write it in
in just a sec. Thank you.
Screen is also a nice alternative.
Install screen and then run from your nodebb dir:
screen -S "screen name" node app
Where "screen name" is the name you want to call the process.
Will detach the screen
screen -R "screen name"
Will reattach the screen.
I've used screen before, actually. Not with NodeBB, but it's neat little tool.
The only thing I don't like is there's no way to reattach back to a screen if you disconnect by accident.
@julian If the screen session is still running then a
Will list the current running screen sessions and then you can just reattach that screen.
I used to use it all the time with Minecraft servers and I use it now with NodeBB in conjunction with supervisor. The only problem i was having with screen is that if the program running in screen crashes, say NodeBB, then the screen session will also terminate. I would then have to ssh back into the server to start it up again. I'm hoping Supervisor will fix this.
Neat, I didn't know this -- thanks @Scuzz! I'll have to give
screenanother try, it seems.