You are not logged in.
Pages: 1
Topic closed
I'm trying to set up some custom dependencies for various services, some of which are supported packages, some are custom packages I've developed. I am running into problems following the procedure described here - specifically, service files in /etc/systemd/system are ignored, and the only way to override them is to edit the files in /usr/lib/systemd/system. I have verified this issue on both a VPS instance and my desktop. Both systems were originally built well before systemd and have been converted to pure systemd systems. Does anyone else see these issues, or know of any reason this would be happening and/or how to resolve it?
Steps to reproduce. This example uses httpd and mysql, but I've tested it with several other services, always with the same results:
Enable the service unit and create a new override:
systemctl enable httpd.service
rm /etc/systemd/system/multi-user.target.wants/httpd.service
cp /usr/lib/systemd/system/httpd.service /etc/systemd/system/multi-user.target.wants/httpd.service
Edit /etc/systemd/system/multi-user.target.wants/httpd.service, adding a line 'Wants=mysqld.service' to the [Unit] section.
Make systemd changes effective, and verify them. The first command results in an error that says "Failed to issue method call: Invalid argument". The final command will show an empty list ("Wants="), when it should list mysqld. Running systemd-delta also shows no override.
systemctl reenable httpd
systemctl daemon-reload
systemctl show -p "Wants" httpd.service
Change the replacement unit file to .include the packaged unit file:
cat > /etc/systemd/system/multi-user.target.wants/httpd.service << __EOF
.include /usr/lib/systemd/system/httpd.service
[Unit]
Wants=mysqld.service
__EOF
Repeat step #3, with the same results
Reenable the package's unit:
rm /etc/systemd/system/multi-user.target.wants/httpd.service
systemctl enable httpd.service
Edit the original unit file in /usr/lib/systemd/system/httpd.service, adding the 'Wants=myslqd.service' to the Unit section
Repeat step 3
Result is the correct and expected one this time ("Wants=myslqd.service")
Last edited by dwheeler (2012-11-14 19:53:10)
Offline
You need to copy the file you want to change to /etc/systemd/system/ , not directly to the multi-user.target.wants/ subdirectory. The objects in the *.wants/ directories need to remain symlinks to the actual unit files. I made this same mistake when I was new to systemd.
Offline
Order matters here. Units are lazily loaded into memory on an as-needed basis.
1) copy the unit to /etc/systemd/system (NOT to the .wants dir)
2) systemctl daemon-reload
3) systemctl enable foo.service # or reenable if applicable
That's all you need to do.
Offline
Thanks, using the correct directory fixed my issue! Guess I should have paid closer attention to the wiki page.
Offline
Well...
I'm still having problems with .service custom files!
I want to customize the ExecStart from original cronie.service file, like this:
# cat /etc/systemd/system/cronie.service
.include /usr/lib/systemd/system/cronie.service
[Service]
ExecStart=/usr/sbin/crond -n -s -m off
==============================
# systemctl restart cronie.service
Failed to issue method call: Unit cronie.service failed to load: Invalid argument. See system logs and 'systemctl status cronie.service' for details.
==============================
# systemd-delta
[OVERRIDDEN] /etc/systemd/system/cronie.service → /usr/lib/systemd/system/cronie.service
--- /usr/lib/systemd/system/cronie.service 2012-11-22 20:04:00.000000000 -0200
+++ /etc/systemd/system/cronie.service 2012-11-27 16:09:49.944085437 -0200
@@ -1,10 +1,3 @@
-[Unit]
-Description=Periodic Command Scheduler
-
+.include /usr/lib/systemd/system/cronie.service
[Service]
-ExecStart=/usr/sbin/crond -n
-ExecReload=/bin/kill -HUP $MAINPID
-Restart=always
-
-[Install]
-WantedBy=multi-user.target
+ExecStart=/usr/sbin/crond -n -s -m off
==============================
# systemctl status cronie.service
cronie.service - Periodic Command Scheduler
Loaded: error (Reason: Invalid argument)
Active: inactive (dead)
CGroup: name=systemd:/system/cronie.service
Nov 27 13:52:59 xpto systemd[1]: Starting Periodic Command Scheduler...
Nov 27 13:52:59 xpto systemd[1]: Started Periodic Command Scheduler.
Nov 27 13:52:59 xpto /usr/sbin/crond[309]: (CRON) INFO (running with inotify support)
Nov 27 14:01:01 xpto /usr/sbin/crond[8216]: pam_unix(crond:session): session opened for user root by (uid=0)
Nov 27 14:01:01 xpto /USR/SBIN/CROND[8217]: (root) CMD (run-parts /etc/cron.hourly)
==============================
What am I doing wrong?
Thanks in advance.
Offline
I'm still having problems with .service custom files!
I want to customize the ExecStart from original cronie.service file, like this:
[...]
What am I doing wrong?
Nothing, it's a limitation of systemd. Exec* commands can't be overridden, only stacked when using "Type=oneshot".
You need to copy the entire file to /etc/systemd/system/ and make your changes there. Don't forget to issue "systemctl reenable cronie.service" to update the link in multi-user.target.wants.
Last edited by Gilrain (2012-11-28 09:00:26)
Offline
fusca wrote:I'm still having problems with .service custom files!
I want to customize the ExecStart from original cronie.service file, like this:
[...]
What am I doing wrong?Nothing, it's a limitation of systemd. Exec* commands can't be overridden, only stacked when using "Type=oneshot".
You need to copy the entire file to /etc/systemd/system/ and make your changes there. Don't forget to issue "systemctl reenable cronie.service" to update the link in multi-user.target.wants.
Thanks Gilrain!
Can you tell me if systemd's team will fix this limitation in a near future?
Offline
No idea but I hope they do. Having to constantly compare service files after each upgrade of cronie and co. is becoming bothersome. Luckily there's systemd-delta...
Offline
Although the problem seems to be solved, I solved a similar problem with tftp server (tftp-hpa 5.2-4) like this.
Let me explain some of my thoughts first:
1. The unit file /usr/lib/systemd/system/tftpd.service contains
...
[Service]
ExecStart=/usr/bin/in.tftpd -s /srv/tftp/
...
2. I want a different directory (/home/frank/tftp/ instead of /srv/tftp/).
3. I don't want to create a full copy of /usr/lib/systemd/system/tftpd.service in /etc/systemd/system/, because it will override all settings. That means, later updates of /usr/lib/systemd/system/tftpd.service would be masked completely.
3. OTOH, I also don't want to edit the global unit file /usr/lib/systemd/system/tftpd.service because I fear problems if the tftp-hpa package is updated.
That's why I created a drop-in directory and a .conf file in /etc/systemd/system/tftpd.service.d/tftpdir.conf to override exactly ExecStart:
[Service]
ExecStart=
ExecStart=/usr/bin/in.tftpd -s /home/frank/tftp/
You have do clear ExecStart= first before you can override it.
Lennart Poettering mentioned this trick on Bugzilla in comment 9 and its implementation in comment 12.
Offline
For me the following worked
sudo cp /usr/lib/systemd/system/httpd.service /etc/systemd/system
sudo vim /etc/systemd/system/httpd.service
sudo systemctl daemon-reload
sudo systemctl restart httpd.service
For locating the unit file I just used
locate httpd.service
Offline
Thread is over four years old and marked solved. Please don't necrobump: https://wiki.archlinux.org/index.php/Co … bumping.22
Closing
Offline
Pages: 1
Topic closed