News for hackers. Stuff that matters.
Re:Systemd v227 by Spidler on Thursday October 08, 2015 @06:19PM (#10356759)
I'm not the same author, but I run several Webapps in systemd units, with the below service for all of them:

Note the @ in the name, that means I reuse it as [email protected] [email protected] and so on.

----8<---- [email protected] ---->8---- [Unit] Description=%i webapp

    [Service]
    User=%i
    Group=%i

    # Note that the first argument of the command line (i.e. the program to execute) 
    # may not include % specifiers.
    ExecStart=/srv/webapp %i
    WorkingDirectory=/srv/%i/

    PrivateTmp=true
    Type=simple
    Restart=always
    RestartSec=2s

    [Install]
    WantedBy=multi-user.target
---- 8< ----

/srv/webapp is a simple script that will do "exec $1/webapp" which is the actual executable.

Re:Systemd v227 by simoncion on Thursday October 08, 2015 @06:26PM (#10356801)
> /srv/webapp is a simple script that will do "exec $1/webapp"

I'm not trying to start a fight.

Why do you call out to a script, rather than having systemd make the call on its own?

Re:Systemd v227 by JdeBP on Thursday October 08, 2015 @08:05PM (#10357259)
It's for the same reason that java has to be invoked as

   /usr/bin/env $JAVA_HOME/bin/java
thus raising questions such as http://unix.stackexchange.com/questions/229523/ .

systemd does not permit variable expansions or unit parameters in the first word of ExecStart.

Re:Systemd v227 by simoncion on Thursday October 08, 2015 @08:13PM (#10357285)
Assuming that your explanation applies to Spidler's situation, why not do

  ExecStart=/bin/sh -c "%i/webapp"
rather than using a one-off wrapper? Does that wrapper ship with systemd?
Re:Systemd v227 by JdeBP on Tuesday October 13, 2015 @12:03PM (#10381346)
No assumption is necessary.
Re:Systemd v227 by simoncion on Tuesday October 13, 2015 @07:06PM (#10384067)
Roger.

Why do the thing Spidler described in his comment, rather than the thing I described in my comment?