<div dir="ltr"><div><div><div><div>Hmm, maybe I'll chuck:<br></div>X-Listen-Port<br></div>X-Listen-Name<br><br></div>On all the generated SystemD units.<br><br></div>Okay, will rewrite to use .socket files. Is there a trick to overcoming the PATH issue which avoids launching bash?<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 2, 2017 at 10:11 PM, Lennart Poettering <span dir="ltr"><<a href="mailto:lennart@poettering.net" target="_blank">lennart@poettering.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Mon, 01.05.17 13:57, Alec Taylor (<a href="mailto:alec.taylor6@gmail.com">alec.taylor6@gmail.com</a>) wrote:<br>
<br>
> Wrote some scripts to generate systemd .service files and start-up those<br>
> services.<br>
><br>
> Currently just for some REST APIs, but soon will include distributed<br>
> systems also.<br>
><br>
> I set the TCP listen port variable that is used by my .service like so:<br>
> `Environment=PORT=4200`<br>
><br>
> To get PATH to work nicely, my `ExecStart` begins with:<br>
> /bin/bash -c 'PATH=bash -c PATH=$PREPEND_PATH:$PATH<br>
><br>
> (would appreciate an alternative to launching a new shell there also!)<br>
><br>
><br>
><br>
</span>> *Is there a systemd trick of explicitly erring on TCP listen-port<br>
> conflicts?*<br>
<span class="">> And/or should I just write a parser that loops through all .service's and<br>
> checks the `PORT=` and raises on conflict?<br>
<br>
</span>No, systemd can't do that for you. And even if it did, this would be<br>
awfully racy as in the time between such a check and the service<br>
trying to ultimately bind() to it something else might already have<br>
taken it.<br>
<br>
I'd generally recommend using socket activation for this, i.e. the<br>
".socket" unit type systemd provides. This howver requires explicit<br>
support in the relevant daemons. Many daemons do support that scheme<br>
out-of-the-box now, but the majority probably does not.<br>
<span class="HOEnZb"><font color="#888888"><br>
Lennart<br>
<br>
--<br>
Lennart Poettering, Red Hat<br>
</font></span></blockquote></div><br></div>