how to keep nodebb start when I reboot ubuntu16.04
-
when I reboot ubuntu,the nodebb need used
./nodebb start
to start
How to keep nodebb auto-startetc
- Upstart
- pm2
- Forever
Which is better?
I'm used
npm install -g forever cd /var/www/nodebb forever start app.js
But it doesn't work when reboot
Ubuntu 16.04.2 LTS
Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
-
@dxxt
systemctl
,For NodeBB < 1.5 I use this configuration (read below), but I don't know if the
ExecStart
script should be updated in the future:Just create a file called
nodebb.service
in/etc/systemd/system
(or/etc/systemd/user
, or any subfolder ofsystemd
), stop nodebb as you run it now and do:sudo systemctl daemon-reload sudo systemctl start nodebb
The configuration file is:
[Unit] Description=NodeBB Service After=system.slice multi-user.target [Service] User=YOUR_USER Group=YOUR_USERGROUP StandardOutput=syslog StandardError=syslog SyslogIdentifier=nodebb Environment=NODE_ENV=production WorkingDirectory=/var/nodebb ExecStart=/usr/bin/node loader.js --no-daemon --no-silent Restart=always [Install] Alias=forum WantedBy=multi-user.target
You can read mode about
systemctl
, that is the integrated Ubuntu service manager, read here -
Updated this in our docs @Giggiux and @Adam-Poniatowski
Running NodeBB - NodeBB Documentation
Documentation portal for NodeBB Forum Software
(docs.nodebb.org)
However, it may need changes if we really do need it to start up after mongo...
-
Step 1 - This will start your nodebb after login in
[Unit] Description=NodeBB forum for Node.js. Documentation=http://nodebb.readthedocs.io/en/latest/ After=system.slice multi-user.target [Service] Type=simple User=your-linux-username StandardOutput=syslog StandardError=syslog SyslogIdentifier=nodebb Environment=NODE_ENV=production WorkingDirectory=/your/nodebb/folder ExecStart=/usr/bin/node /your/nodebb/folder/loader.js --no-daemon --no-silent Restart=always [Install] WantedBy=multi-user.target
Step 2 - On terminal - This will start your nodebb on boot-up
loginctl enable-linger your-linux-username
-
@Giggiux That is correct. It will keep restarting until mongo/redis has started. I added mongod.service in the After parameter and does startup normally. I know mongod takes a minute or 2 to start, as I have tested this and nodebb is in the failed state until mongod has fully started. Sometimes mongod will show that it has started but nodebb fails to start. I just waited a couple of minutes and checked nodebb again (systemctl status nodebb) and it was up/active, without my intervention