Discussion:
Formatting Execstart= for readability
(too old to reply)
Kai Hendry
2017-08-16 07:52:31 UTC
Permalink
Raw Message
Hi there,

I maintain a service file with a lot of switches in the ExecStart
https://github.com/kaihendry/pingprom/blob/master/prometheus%40.service#L8

I want to almost document each switch ... e.g.
-storage.local.retention=8544h # keep data for a year

I know inline comments do *not* work in bash IIUC:
https://gist.github.com/kaihendry/ff751622c6454176837b1c340b5cfccb

And similarly when I try break up lines on something like
https://s.natalian.org/2017-08-16/test.service

[Service]
ExecStart=/usr/bin/curl -X POST
-d "fizz=systemd" # some docs
-d "some=else" # more docs
https://requestb.in/19v8a0m1


It also doesn't work. Am I missing a tool or way to better
format/document process arguments like I want?

Many thanks!
Mantas Mikulėnas
2017-08-16 08:31:00 UTC
Permalink
Raw Message
Post by Kai Hendry
Hi there,
I maintain a service file with a lot of switches in the ExecStart
https://github.com/kaihendry/pingprom/blob/master/prometheus%40.service#L8
I want to almost document each switch ... e.g.
-storage.local.retention=8544h # keep data for a year
https://gist.github.com/kaihendry/ff751622c6454176837b1c340b5cfccb
And similarly when I try break up lines on something like
https://s.natalian.org/2017-08-16/test.service
[Service]
ExecStart=/usr/bin/curl -X POST
-d "fizz=systemd" # some docs
-d "some=else" # more docs
https://requestb.in/19v8a0m1
It also doesn't work. Am I missing a tool or way to better
format/document process arguments like I want?
Just put everything in a shell script. (That way you can test it directly
without systemd, too.)

With bash, you can use inline comments in arrays:

#!/usr/bin/env bash
args=(
-X POST # foo
-d "fizz=systemd" # some docs
-d "some=else" # more docs
https://requestb.in/foo
)

exec curl "${args[@]}"
--
Mantas Mikulėnas <***@gmail.com>
Jérémy Rosen
2017-08-16 08:40:08 UTC
Permalink
Raw Message
Post by Kai Hendry
Hi there,
I maintain a service file with a lot of switches in the ExecStart
https://github.com/kaihendry/pingprom/blob/master/prometheus%40.service#L8
<https://github.com/kaihendry/pingprom/blob/master/prometheus%40.service#L8>
I want to almost document each switch ... e.g.
-storage.local.retention=8544h # keep data for a year
https://gist.github.com/kaihendry/ff751622c6454176837b1c340b5cfccb
<https://gist.github.com/kaihendry/ff751622c6454176837b1c340b5cfccb>
And similarly when I try break up lines on something like
https://s.natalian.org/2017-08-16/test.service
<https://s.natalian.org/2017-08-16/test.service>
[Service]
ExecStart=/usr/bin/curl -X POST
-d "fizz=systemd" # some docs
-d "some=else" # more docs
https://requestb.in/19v8a0m1
It also doesn't work. Am I missing a tool or way to better
format/document process arguments like I want?
Just put everything in a shell script. (That way you can test it
directly without systemd, too.)
Alternatively, you could documente everything in an EnvironmentFile that
sets an environment variable with all the parameters and documents in a
comment

Regards
Jérémy
--
Post by Kai Hendry
#!/usr/bin/env bash
args=(
-X POST # foo
-d "fizz=systemd" # some docs
-d "some=else" # more docs
https://requestb.in/foo
)
--
_______________________________________________
systemd-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
Logo <http://www.smile.fr/>

20 rue des Jardins
92600 AsniÚres-sur-Seine
www.smile.fr <http://www.smile.fr/>
*Jérémy ROSEN*
Architecte technique
Email : ***@smile.fr <mailto:***@smile.fr>
Tel : +33141402967

Facebook <https://www.facebook.com/smileopensource> Google%2B
<http://fr.slideshare.net/SmileOpenSource/presentations> LinkedIn
<https://www.linkedin.com/company/smile> Twitter
<https://twitter.com/GroupeSmile>


bandeaux_mail
<http://www.smile.fr/Offres-services/Offres/Ingenierie?utm_source=signature&utm_medium=email&utm_campaign=signature>

eco Pour la planÚte, n'imprimez ce mail que si c'est nécessaire
Reindl Harald
2017-08-16 09:09:23 UTC
Permalink
Raw Message
Post by Mantas Mikulėnas
Just put everything in a shell script. (That way you can test it
directly without systemd, too.)
#!/usr/bin/env bash
args=(
-X POST # foo
-d "fizz=systemd" # some docs
-d "some=else" # more docs
https://requestb.in/foo
)
this is the worst recommendation one can give - really - that way you
easily lose all the advantages of systemd in case of error handling
Mantas Mikulėnas
2017-08-16 10:04:30 UTC
Permalink
Raw Message
Post by Reindl Harald
Post by Mantas Mikulėnas
Just put everything in a shell script. (That way you can test it directly
without systemd, too.)
#!/usr/bin/env bash
args=(
-X POST # foo
-d "fizz=systemd" # some docs
-d "some=else" # more docs
https://requestb.in/foo
)
this is the worst recommendation one can give - really - that way you
easily lose all the advantages of systemd in case of error handling
For example?
--
Mantas Mikulėnas <***@gmail.com>
Reindl Harald
2017-08-16 10:09:01 UTC
Permalink
Raw Message
Post by Mantas Mikulėnas
Just put everything in a shell script. (That way you can test it
directly without systemd, too.)
#!/usr/bin/env bash
args=(
-X POST # foo
-d "fizz=systemd" # some docs
-d "some=else" # more docs
https://requestb.in/foo
)
this is the worst recommendation one can give - really - that way
you easily lose all the advantages of systemd in case of error handling
For example?
what is the MAINPID - bash or curl - in that case?

why inthe world should someone sacrifice the advantage of having the
executebale directly started because of inline comments where a smart
comments-block does the same

[Service]
ExecStart=/usr/bin/curl -X POST
-d "fizz=systemd" # some docs
-d "some=else" # more docs

versus

[Service]
# fizz: somedocs
# some: moredocs
ExecStart=/usr/bin/curl -X POST -d "fizz=systemd" -d "some=else"
Mantas Mikulėnas
2017-08-16 10:41:41 UTC
Permalink
Raw Message
Post by Reindl Harald
Post by Mantas Mikulėnas
Just put everything in a shell script. (That way you can test it
directly without systemd, too.)
#!/usr/bin/env bash
args=(
-X POST # foo
-d "fizz=systemd" # some docs
-d "some=else" # more docs
https://requestb.in/foo
)
this is the worst recommendation one can give - really - that way
you easily lose all the advantages of systemd in case of error handling
For example?
what is the MAINPID - bash or curl - in that case?
curl, since `exec` preserves the PID.
--
Mantas Mikulėnas <***@gmail.com>
Colin Guthrie
2017-08-16 10:15:34 UTC
Permalink
Raw Message
Post by Kai Hendry
Hi there,
I maintain a service file with a lot of switches in the ExecStart
https://github.com/kaihendry/pingprom/blob/master/prometheus%40.service#L8
I want to almost document each switch ... e.g.
-storage.local.retention=8544h # keep data for a year
https://gist.github.com/kaihendry/ff751622c6454176837b1c340b5cfccb
And similarly when I try break up lines on something like
https://s.natalian.org/2017-08-16/test.service
[Service]
ExecStart=/usr/bin/curl -X POST
-d "fizz=systemd" # some docs
-d "some=else" # more docs
https://requestb.in/19v8a0m1
It also doesn't work. Am I missing a tool or way to better
format/document process arguments like I want?
Many thanks!
Write a companion man page and/or web page and reference it in
Documentation=

Col
--
Colin Guthrie
colin(at)mageia.org
http://colin.guthr.ie/

Day Job:
Tribalogic Limited http://www.tribalogic.net/
Open Source:
Mageia Contributor http://www.mageia.org/
PulseAudio Hacker http://www.pulseaudio.org/
Trac Hacker http://trac.edgewall.org/
Loading...