Start NodeBB on system boot
-
-
@Guiri Yep. There are many ways. I prefer having a nice script which can do start/stop tasks when I call it in one place with all the other start/stop scripts. You prefer a solution which is more behind the scenes. But at the end of the day, both will work The OP will have to choose what he wants to do
-
... there was an article on using Upstart in the wiki, but I cleared out the wiki and didn't notice it wasn't migrated to the documentation...
In any case, this is the upstart config I use in running this forum:
start on startup stop on runlevel [016] respawn setuid julian setgid julian script cd /path/to/my/nodebb ./nodebb start end script
Edit: I think you might need a
--no-daemon
tacked on to the end of the./nodebb start
... -
@julian Not working for me. I'm using ubuntu. I tried your Upstart script with and without the
--no-daemon
, I can see the process listed but the forum is not started. With--no-daemon
it minified in infite loop.I am using nginx and user www-data
setuid www-data
is that a problem?su - www-data -c '/srv/www/mywebsite/nodebb/nodebb start' No directory, logging in with HOME=/ This account is currently not available.
well I created an user for nodebb, but the problem persist. I am not able to boot nodebb at startup.
i am wondering about the other proposed script, they will start nodebb with root!? is that ok?
it would be very nice to have a better documentation for this part on https://docs.nodebb.org/en/latest/running/index.html
-
@eEight Who owns the files in
/src/www/mywebsite/nodebb
? The user starting nodebb should be a user that has write access to that folder (at the very least).If you're calling
setuid www-data
, there's no need to prefix the./nodebb start
command withsu - www-data
-
@julian Looks like it's impossible to run nodebb with www-data (nginx user), because www-data doesn't have a "real" account. So I created an user
nodebb
and use your script in/etc/init/nodebb.conf
start on startup stop on runlevel [016] respawn setuid nodebb setgid nodebb script cd /srv/www/mywebsite/nodebb ./nodebb start end script
When booting my server = nodebb is not started. I have to do manually
service nodebb start
then it works. -
@eEight Why would you want to start NodeBB with
www-data
? I'm pretty sure that running NodeBB withroot
won't rise a security risk.Anyway, try adding this script as a
init.d
service in/etc/init.d/nodebb/
. I'm pretty sure it will boot your NodeBB instance flawlessly, as I'm using basically the same script.
(Ubuntu)#! /bin/bash # /etc/init.d/nodebb case "$1" in start) echo "Starting NodeBB..." cd /srv/www/community/nodebb ./nodebb start ;; stop) echo "Stopping NodeBB..." cd /srv/www/community/nodebb ./nodebb stop ;; *) echo "Usage: /etc/init.d/nodebb {start|stop}" exit 1 ;; esac exit 0
-
Re: starting NodeBB as root user:
Conventionally, this is not encouraged as it breaks the "rule of least privilege". Processes should have as restrictive a set of privileges as possible so that in the event that a malicious user is able to "break out" of the app and into a command line environment, they are only able to do a limited amount of damage.
If a malicious user broke out and was automatically a root user, there is no limit to what he/she could do.
-
Found this sample for startup node app's shell:
https://github.com/chovy/node-startup.gitEasy to use & Save times.
-
just put in cronjob something like this:
@reboot cd <path>/<to>/<nodebb> && ./nodebb start
that would do the startup trick.
Until the latest version pm2 was doing a good job. -
start on startup stop on runlevel [016] respawn setuid nodebb setgid nodebb script cd /srv/www/mywebsite/nodebb node loader.js --no-silent --no-daemon end script
This script (from https://docs.nodebb.org/en/latest/running/index.html) has been working for me forever on 0.6.x but is no longer starting NodeBB on startup. /var/log/upstart/nodebb.log contains this, repeated over and over again:
events.js:85 throw er; // Unhandled 'error' event ^ Error: EROFS, open '/opt/nodebb/logs/output.log' at Error (native) events.js:85 throw er; // Unhandled 'error' event ^ Error: EROFS, open '/opt/nodebb/logs/output.log' at Error (native)
Anyone have a clue what might be broken?
sudo start nodebb
works as expected, as does./nodebb start
andnode loader.js --no-silent --no-daemon
works when I log in to the console. I replaced that line with./nodebb start
and it seems to work. Is this just a case of the docs being out of date or is this something I should be concerned about? -
Here is what my startup script looks like on ubuntu 14.10 (my nodebb is run under my username)
-
@julian But that's not really possible. I can start it under my user account, even using the same command and it starts from the startup script after I changed it to
./nodebb start
... and it was working for months before I upgraded to 0.7.2 and just suddenly stopped because of it. And starting it from any other method does write output to /opt/nodebb/logs/output.log:nodebb@NodeBB:/opt/nodebb/logs$ ls -la total 20 drwxrwxr-x 2 nodebb nodebb 4096 Aug 4 06:55 . drwxr-xr-x 10 nodebb nodebb 4096 Aug 4 07:28 .. -rw-rw-r-- 1 nodebb nodebb 6 Aug 4 06:51 .gitignore -rw-rw-r-- 1 nodebb nodebb 5021 Aug 4 07:28 output.log
I ran into so many problems after this upgrade that I just threw the whole instance away (
mv /opt/nodebb /opt/nodebb_old
) made a new directory and installed using the steps from https://docs.nodebb.org/en/latest/installing/os/ubuntu.html starting with the repository clone:git clone -b v0.7.x https://github.com/NodeBB/NodeBB.git nodebb cd nodebb npm install --production ./nodebb setup
I ended up copying the old config.json file back into the new directory because I was too lazy to copy and paste the secret, but I am otherwise now running a brand spankin' new install of v0.7.2 and I hit the same problem. same EROFS error in /var/log/upstart/nodebb.log after I put the old /etc/init/nodebb.conf back.
I also have a minor problem with the persona theme (.taskbar CSS class has a width of 50% specified in stylesheet.css even after updating the theme to the latest from the ACP), a plugin that completely breaks the service whenever a topic is loaded (nodebb-plugin-topic-badges) and a plugin that tries to turn every link that starts with http:// into a YouTube embed (nodebb-plugin-youtube-lite).
The clean install did fix a problem I was having with the chat windows.Nevermind. Updating the theme in the ACP broke the chat windows again, so that's the problem with that one.