9

I have a service with WorkingDirectory=/srv/ctr/current which is a symlink.

It seems the service doesn't pick up changes in the symlink when restarted. The error log reports /srv/ctr/releases/69 as the location but the /srv/ctr/current points to /srv/ctr/releases/72. Is there any way I can get systemd to pick up on the new directory change?

5
  • Have you tried systemctl daemon-reload? Might trigger a re-read of the symlink.
    – morloch
    Commented Nov 10, 2015 at 1:02
  • @morloch yes I tried that. The service which I'm running is resque. I'm wondering if the path is somehow stored in the job itself. Commented Nov 10, 2015 at 3:10
  • 3
    Try adding ExecStartPre=/bin/pwd -P to your service, reload/restart the service and check the logs. At least then you'll know if it's systemd or resque...
    – morloch
    Commented Nov 10, 2015 at 6:06
  • @morloch that worked and now somehow it's finding the right directory. Commented Nov 17, 2015 at 12:34
  • I had the same issue. SystemD will resolve the SymLink to the actual path and use that. I've not found a way to disable this behavior. I've now simply moved my stuff to the symlink target and create a new link in the other direction... Commented Feb 24, 2017 at 17:55

2 Answers 2

2

Possibly try adding:

Environment = PWD=/srv/ctr/current

(BTW, really happy to see someone else using /srv/* for their services.)

1
  • 1
    Old question, but wanted to say that this worked for me on Centos 8.1's systemd while @morloch's comment did not.
    – Yoopergeek
    Commented Apr 4, 2020 at 2:57
0

modify your systemd unit file to be as follows:

  • WorkingDirectory=/srv/ctr/
  • ExecStart=/bin/start current or ExecStart= cd current && /bin/start

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .