I am trying to change Mopidy to run as root when it is ran as a service.
I have edited /etc/init.d/mopidy to have: DAEMON_USER=root
however when I run Mopidy either by restarting or doing whole dance of:
sudo service mopidy stop
sudo service mopidy start
Mopidy still starts with the mopidy user.
Which I can tell by doing: ps aux | grep -i mopidy
mopidy 10409 41.4 7.6 256864 72604 ? Ssl 17:17 0:14 /usr/bin/python /usr/bin/mopidy --config /usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf
I’m guessing that you’re on a Debian based system that is now running systemd, not sysvinit. Thus /etc/init.d/mopidy is unused because /lib/systemd/system/mopidy.service is used instead.
If I’m right, don’t change the file in /lib/systemd/... but create a new empty file in /etc/systemd/... with the same name. In it, you can override the parts of the /lib/systemd/... file you want, while still get the future improvements to the systemd service file when you upgrade the mopidy package.
I think something like this in /etc/systemd/system/mopidy.service should work:
I was figuring it was because of the OS, and giving my OS would be of more help.
When I created the file you said and then started up, nothing different happened.
It does work if I modify /lib/systemd/system/mopidy.service but to your point the ideal way would be to not edit that file.
Unfortunately I am not sure what more I can say then it simply didn’t work.
It didn’t work the first time because @jodal was trying to define a systemd ‘Drop-in snippet’ where you only override the specific settings you want to change and leave everything untouched. The benefit of this being that if/when there is a new version of Mopidy released which requires a different ExecStart setting then you’ll get this change automatically.
For a ‘Drop-in snippet’ to work it seems you actually need to create the file /etc/systemd/system/mopidy.service.d/my-override.conf. What you’ve done now will work, but in theory it may become a problem in the future.