CentOS 7 systemd file not working?

Trying to get Sonarr installed on CentOS7, but am not having much luck with the systemd file. I can manually start Sonarr using the ExecStart command I have set, but it spills out to logs to the console.

How can I prevent all the output (i.e., run as an actual daemon), or what’s wrong with my systemd script?

#
# Systemd unit file for Sonarr
#

[Unit]
Description=Sonarr Daemon

[Service]
Type=simple
User=usenet
Group=usenet
ExecStart=/usr/bin/mono /apps/sonarr/NzbDrone.exe -nobrowser -data /apps/data/.sonarr
TimeoutStopSec=20

[Install]
WantedBy=multi-user.target

Here’s the error I get when I run systemctl start sonarr.service

[root@centos7-test log]# systemctl status sonarr.service -l
sonarr.service - Sonarr Daemon
   Loaded: loaded (/etc/systemd/system/sonarr.service; disabled)
   Active: failed (Result: exit-code) since Wed 2015-11-04 11:04:07 EST; 195ms ago
  Process: 1976 ExecStart=/usr/bin/mono /apps/sonarr/NzbDrone.exe -nobrowser -data /apps/data/.sonarr & (code=exited, status=1/FAILURE)
 Main PID: 1976 (code=exited, status=1/FAILURE)

Nov 04 11:04:07 centos7-test mono[1976]: at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00000] in <filename unknown>:0
Nov 04 11:04:07 centos7-test mono[1976]: at System.IO.Directory.CreateDirectory (System.String path) [0x00000] in <filename unknown>:0
Nov 04 11:04:07 centos7-test mono[1976]: at NzbDrone.Common.Disk.DiskProviderBase.CreateFolder (System.String path) [0x00000] in <filename unknown>:0
Nov 04 11:04:07 centos7-test mono[1976]: at NzbDrone.Common.Disk.DiskProviderBase.EnsureFolder (System.String path) [0x00000] in <filename unknown>:0
Nov 04 11:04:07 centos7-test mono[1976]: at NzbDrone.Common.EnvironmentInfo.AppFolderFactory.Register () [0x00000] in <filename unknown>:0
Nov 04 11:04:07 centos7-test mono[1976]: at NzbDrone.Host.Bootstrap.Start (NzbDrone.Common.EnvironmentInfo.StartupContext startupContext, IUserAlert userAlert, System.Action`1 startCallback) [0x00000] in <filename unknown>:0
Nov 04 11:04:07 centos7-test mono[1976]: at NzbDrone.Console.ConsoleApp.Main (System.String[] args) [0x00000] in <filename unknown>:0
Nov 04 11:04:07 centos7-test mono[1976]: Press any key to exit...
Nov 04 11:04:07 centos7-test systemd[1]: sonarr.service: main process exited, code=exited, status=1/FAILURE
Nov 04 11:04:07 centos7-test systemd[1]: Unit sonarr.service entered failed state.

Any idea what is going on here? I’m not familiar with mono at all, but I am running version 4.0.1.

Thanks!

You should use the --debug flag, but it looks like Sonarr is failing to create the /apps/data/.sonarr folder. Perhaps permissions?

I also thought it was something to do with that directory, but it exists and is owned by usenet:usenet.

I wasn’t aware of --debug, but I’m not seeing any difference when adding --debug in my systemd script. If I run my ExecStart script from bash, it starts just fine. I just don’t get it.

Hang tight, and I will revert this VM and share a full step-by-step of my install and what I’m seeing. Maybe that will help.

EDIT:
Just figured something out. In /var/log/message I found this:
Nov 4 17:02:05 centos7-test mono: System.UnauthorizedAccessException: Access to the path "/home/usenet" is denied.

Which makes sense, since /home/usenet doesn’t exist. When I create my usenet use, I use useradd -r usenet which doesn’t create a home dir. I manually created /home/usenet and set permissions on it for usenet:usenet and systemd was able to start sonarr. Now I find /home/usenet/.config/NzbDrone which contains configs, logs, etc. I don’t want those files there. I want those to live in /apps/data/.sonarr, and I thought the -data flag was supposed to set that.

Any idea?

EDIT2:
Well, I figured it out. The flag -data /apps/data/.sonarr is not a valid flag. Instead I have to use --data=/apps/data/.sonarr, and it’s working now (at least at the surface level of things). I’d suggest updating documentation for this since the few systemd scripts I found reference using -data /path/to/dir.

1 Like

Well found on that data path! I was leaving it at the defaults but have been wanting to move it. I changed my Centos service here to match yours… works perfect!

LJ

At the moment the data switch isn’t supported (which is why we don’t have any documentation on its existence), it was originally added for testing purposes though we have been working towards supporting it.

Interestingly, on a different CentOS 7 box, --data=/path/tp/dir didn’t work. But I’m finding that /data=path/to/dir is working like expected. I’m not sure why I am seeing variances, but I’m just glad I managed to get it consistently working.

At one time, I did manage to find something that that resembled using a --help flag, that referenced for flags…but I can’t remember how I found it. I know it referenced /nobrowser and /data, but I don’t remember the others. IMO, adding support for that /data flag is vital for me to use Sonarr long term. Any application I run as a daemon, I don’t want it storing data in a user directory.

Anyway, I updated a blog post on my site to install Sonarr on CentOS 7, if anyone is interested:

Section #6, specially covers Sonarr. Seems to work well enough, and I can get repeatable results.

haha… small world. Your blog is actually the one I used to setup CP/Headphones/etc on my new journey using a linux server at home full time. Thanks for that!

LJ

Glad you like my blog @lordjynx, and your welcome!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.