Starting with systemd only works as root
-
Here is a working .service, but I concur with @julian, do not put your nodebb inside the /root folder. Pretty good chance it will ruin your security at some point.
[Unit] Description=NodeBB Documentation=https://docs.nodebb.org After=system.slice multi-user.target mongod.service [Service] Type=simple User=nodebb StandardOutput=syslog StandardError=syslog SyslogIdentifier=nodebb WorkingDirectory=/var/www/nodebb/NodeBB/ ExecStart=/usr/bin/env node loader.js --no-silent --no-daemon Restart=always [Install] WantedBy=multi-user.target
-
@wayne-workman said in Starting with systemd only works as root:
My nodebb directory is here: /root/nodebb
This is the private home directory for the root user. It's sole purpose is to lock things down to root. Use /opt for system level software.
-
@scottalanmiller I always wondered... Is it an anti pattern to change ownership of folders in /opt to specific users? I always assumed everything in there was supposed to be owned by root too
-
@julian said in Starting with systemd only works as root:
@scottalanmiller I always wondered... Is it an anti pattern to change ownership of folders in /opt to specific users? I always assumed everything in there was supposed to be owned by root too
/opt is definitely open to "user owned" files. We assume that it will be "service users" rather than end users. So users like apache, nodebb, etc.
You would treat /opt exactly the same as you would treat /var/www/html which "always" uses a service user for file ownership.
-
@scottalanmiller said in Starting with systemd only works as root:
@wayne-workman said in Starting with systemd only works as root:
My nodebb directory is here: /root/nodebb
This is the private home directory for the root user. It's sole purpose is to lock things down to root. Use /opt for system level software.
or /srv
-
@The-Worms said in Starting with systemd only works as root:
@scottalanmiller said in Starting with systemd only works as root:
@wayne-workman said in Starting with systemd only works as root:
My nodebb directory is here: /root/nodebb
This is the private home directory for the root user. It's sole purpose is to lock things down to root. Use /opt for system level software.
or /srv
That works, too. But is non-standard. I prefer /opt because of 50 years of where we expect the software to go.
But I use /srv sometimes, too.
-
I did get this working.
I moved the nodebb working directory to/home/nodebb/nodebb
and changed ownership of that tonodebb:nodebb
, now it starts up on boot as the nodebb user just fine.Thank you all very much for the help.