Tried to use guest mode in chrome with no go. So this is not cache related. Tips?
Anyone else experience this?
Hey,
How do you guys start NodeBB automatically on system boot? I found this Upstart script over here: https://www.exratione.com/2013/02/nodejs-and-forever-as-a-service-simple-upstart-and-init-scripts-for-ubuntu/. However, after I edited this to match my Node & NodeBB paths etc., it gives me an error.
[email protected]:/etc/init# start nodebb
start: Job failed to start
Here is the script I'm using. http://pastebin.com/M1uNFkPi
There are different possibilities. Unfortunately, I don't know much about Ubuntu. But I guess, it should be the same as on Debian.
In /etc/init.d
there are scripts which are run on system startup with start
as parameter and stop
on system shutdown. All you have to do is make such a little script which takes 1 parameter and either starts nodebb if the parameter is start or stop nodebb if the parameter is stop.
#! /bin/sh
# /etc/init.d/nodebb
case "$1" in
start)
echo "Starting NodeBB..."
/srv/www/community/nodebb start
;;
stop)
echo "Stopping NodeBB..."
/srv/www/community/nodebb start
;;
*)
echo "Usage: /etc/init.d/nodebb {start|stop}"
exit 1
;;
esac
exit 0
Have a look into forever or supervisor. They're in the nodebb documentation.
@a_5mith I don't think forever or supervisor start nodebb after system start. Please correct me if I am wrong.
@Marco The Debian script you provided uses the built-in NodeBB start function(?), which is okay, but I need the script to start a forever instance. How can do that?
@Marco I use @reboot /usr/local/bin/forever /my/nodebb/app.js start
in my crontab. That seems to do the trick.
@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 with su - 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 with root
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.
Not sure why but the UpStart script from @julian is not launched at boot. I have to manually log and type service nodebb start
then it works (launching nodebb with the right user & group).
Found this sample for startup node app's shell:
https://github.com/chovy/node-startup.git
Easy 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
and node 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)
@Shaun, the EROFS error points to /opt/nodebb
not being a writable file system... as far as I know, that upstart script still works, as I am using it myself.