Need help with custom .service
Hey there,
I just installed arch linux to run a teamspeak server. I've already installed Teamspeak and everything runs when I run it as root. I've created a user by doing:
useradd teamspeak3 -m -s /usr/bin/nologin
Now I created a teamspeak3.service so that teamspeak will run on boot and will be run by the user teamspeak3:
[Unit]
Description=Teamspeak Server Service
Wants=network.target
[Service]
WorkingDirectory=/home/teamspeak3/teamspeak3server
User=teamspeak3
ExecStart=/home/teamspeak3/teamspeak3server/ts3server_startscript.sh start
ExecStop=/home/teamspeak3/teamspeak3server/ts3server_startscript.sh stop
ExecReload=/home/teamspeak3/teamspeak3server/ts3server_startscript.sh restart
For some reason whenever I start the service and show the status it says it failed with (code=exited, status=200/CHDIR) behind the ExecStart and ExecStop.
Could you guys help me out?:)
About this post
- Posted
- Archived
- Score
- 4 · 100% up
- Kind
- Text
- ID
- 2lavs8
18 comments
I suspect you need
Type=<something>in the[Service]section, because by default systemd expects the program you run inExecStartto keep running as long as the service is running. Readman systemd.servicefor the details of the different options.Ultimately, it's probably better to figure out what
ts3server_startscript.sh startactually does and make the service do that directly.Can you try adding Type=forking in the [Service] section. Is there any output in the journal from the script?
Also, for consitency, you might want to add After=network.target so that the server is started after networking and not in parallel.
I tried adding the type=forking and it still crashes, the output is changed though:
When I cd to /home/teamspeak3/teamspeak3server/ nothing goes wrong and I can see the startscript there...
Hmmm... Silly question, but does /bin/sh exist on your system?
Either way, can you try prepending /bin/bash (or where ever bash is) to all the Exec directive so they look like this: ExecStart=/bin/bash /home/teamspeak3/teamspeak3server/ts3server_startscript.sh start
Why not simply use the AUR package that comes with a service and stuff?
I'm kind of a newbie and I couldn't get it fixed with the AUR package. So I just downloaded the .tar.gz from teamspeak and started figuring things out myself...
edit: And why not learn how to write a .service by yourself?:)
What exactly needed fixing?
Deleted before we saved it.
So instead of using a pre-configured and very well set up package that you only need to install and use (because the package maintainer already did all the necessary work for you) you thought you better do it by yourself because you are a newbie? Makes total sense … :D
Not sure on writing services but 'status=200/CHDIR' was the same error I got when starting btsync with the btsync.conf only readable by root. 'ls -l' to make sure user teamspeak3 owns or at least can read that script.
Outside of that I got nothing.
the /ts3server_startscript.sh has the following ls -l:
-rwxrwxr-x, so that should be ok right?
Yeah as long as it's owned by that user that's fine. Sorry can't be any more help.