Cannot start nodebb with systemd
-
Hi there,
I installed NodeBB following the documentation, and all seems working well.
Now, I want start NodeBB using systemd, so if I reboot the server, NodeBB will start automatically.
For doing so, I created a service called "nodebb.service" with the following content:[Unit] Description=NodeBB forum for Node.js. Documentation=http://nodebb.readthedocs.io/en/latest/ After=system.slice multi-user.target [Service] Type=simple User=sfarzoso StandardOutput=syslog StandardError=syslog SyslogIdentifier=nodebb Environment=NODE_ENV=production WorkingDirectory=/opt/nodebb ExecStart=/usr/bin/node loader.js --no-daemon --no-silent Restart=always [Install] WantedBy=multi-user.target
when I execute: "systemctl start nodebb.service" the service fail to start, infact when I do: "systemctl status nodebb.service" I get: "Start request repeated too quickly".
I tried to execute "/usr/bin/node loader.js --no-daemon --no-silent" and iI reiceve:
Error: Cannot find module '/sfarzoso/loader.js'
maybe is this the problem?
Any suggestion to fix that?Kind regards and congrats for your amazing community platform
-
@sfarzoso try changing
loader.js
to/opt/nodebb/loader.js
-
Hi, thanks for the answer I changed as you suggested:
ExecStart=/usr/bin/node /opt/nodebb/loader.js --no-daemon --no-silent
so I did this step:
systemctl daemon-reload systemctl start nodebb.service systemctl status nodebb.service
and I get:
Failed to start NodeBB forum for Node.js
the weird thing is that if I execute this:
/usr/bin/node /opt/nodebb/loader.js --no-daemon --no-silent
nodebb start correctly, so I don't get what is wrong in my service configuration
-
@julian said in Cannot start nodebb with systemd:
/opt/nodebb/logs/output.log
Hi julian, sorry for my delay response.
I changed the services as you suggested, essentially this was my first implementation.I removed the file output.log, then I rebooted the system and started the services, when I went in the logs folder the file output.log was empty.
UPDATE:
I used journalctl -fu nodebb.service to see the log of the service, and I discovered a nice thing:
Any idea?
UPDATE 2 [FIXED]
Okay, so after spending some times on this, I discovered what is the cause of the problem. Essentially, I have installed nodebb as root account (which is wrong, my bad), and the systemd service was configured to run nodebb as the user "sfarzoso", but that user was not the owner of nodebb folder, so when I started the service using systemd, a permission problem happen.
For fix this, I chowned the "opt" folder for "sfarzoso", which is the folder that I need to install nodebb, then I cloned the repo of nodebb and launched the setup again.
All works now.Thanks for the attention, king regards.