On Thu, 03.01.13 21:23, Thomas Schreiber ([email protected]) wrote: > Hi, > > I've followed this example with success: http://superuser.com/a/393429/77086 > > However, I am trying to do one more variable substitution by altering the > path to the executable used by ExecStart: > > # cat /usr/lib/systemd/system/[email protected] > [Unit] > Description=uWSGI service for %i > After=syslog.target > > [Service] > ExecStart=/srv/.virtualenvs/%i/bin/uwsgi --ini /etc/uwsgi/%i.ini > ExecReload=/bin/kill -HUP $MAINPID > KillSignal=SIGINT > Restart=always > Type=simple > > [Install] > WantedBy=multi-user.target > > # systemctl status uwsgi@myproject > [email protected] - uWSGI service for myproject > Loaded: loaded (/usr/lib/systemd/system/[email protected]; enabled) > Active: failed (Result: start-limit) since Thu, 2013-01-03 14:01:31 > CST; 4s ago > Process: 23921 ExecStart=/srv/.virtualenvs/%i/bin/uwsgi --ini > /etc/uwsgi/%i.ini (code=exited, status=203/EXEC) > CGroup: name=systemd:/system/[email protected]/myproject > > systemd[1]: Started uWSGI service for myproject. > systemd[1]: [email protected]: main process exited, code=exited, > status=203/EXEC > systemd[1]: Unit [email protected] entered failed state > systemd[1]: Stopping uWSGI service for myproject... > systemd[1]: Starting uWSGI service for myproject... > systemd[1]: Failed to start uWSGI service for myproject. > systemd[1]: Unit [email protected] entered failed state > > # cat /etc/issue > Arch Linux \r (\l) > > # uname -a > Linux noufos 3.6.10-1-ARCH #1 SMP PREEMPT Tue Dec 11 09:40:17 CET 2012 > x86_64 GNU/Linux > > # systemctl --version > systemd 196 > arch > +PAM -LIBWRAP -AUDIT -SELINUX -IMA -SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ > > Everything in this script works except the first %i variable on the > ExecStart line because I can get the service to start correctly simply by > hardcoding the path to the uwsgi executable: > > ExecStart=/srv/.virtualenvs/myproject/bin/uwsgi --ini /etc/uwsgi/%i.ini > > So I am wondering if this is a bug or intentional behavior. Alternative > suggestions to using the template appreciated.
This is intentional behaviour. This is only documented indirectly however (i.e. systemd.service(5) says that env vars are not replaced for the first argument, but % specifiers are also not replaced. I have now changed git to clarify this. The reason behind this is that on SELinux systems we might need to know the path of a binary before a service is instantiated (in order to label things correctly). This becomes really hard if the first argument is dynamic. We could in theory lift this limitation in a number of cases, but I am afraid of lifting this entirely in order to make sure that unit files written on non-SELinux systems still work fine on SELinux systems... A simple work-around is to invoke your command through /usr/bin/env. Lennart -- Lennart Poettering - Red Hat, Inc. _______________________________________________ systemd-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/systemd-devel
