Antw: [EXT] Best practices for lots of similar units?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

Two random thoughts: If you write a wrapper script for ExecStart that just
receives two parameters, the commend line would look more simple.
If you encode both parameters into one (and the script decodes them, one
parameter for systemd would do. Like USER%CODEBASE.

Regards,
Ulrich

>>> Roman Odaisky <roma@xxxxxxxxxxx> schrieb am 23.07.2020 um 23:12 in
Nachricht
<4042427.ejJDZkT8p0@xps>:
> Hi All,
> 
> Suppose I want to run a number of similar services that all require the same

> 
> boilerplate. How to avoid repeating myself when creating unit files?
> 
> Let’s take a concrete example, websites. The boilerplate is as follows:
> 
> [Unit]
> After=syslog.target
> 
> [Service]
> ExecStart=/usr/bin/uwsgi \
>     --socket /run/uwsgi/USER/CODENAME.sock \
>     --plugin python3 \
>     --plugin logfile \
>     --logto /srv/CODENAME/logs/uwsgi.log \
>     --logfile-chmod 644 \
>     --virtualenv /srv/CODENAME/venv \
>     --pythonpath /srv/CODENAME/app \
>     --chdir /srv/CODENAME/app \
>     --env DJANGO_SETTINGS_MODULE=settings \
>     --module django.core.wsgi:get_wsgi_application() \
>     --procname-prefix "CODENAME " \
>     --ini /etc/uwsgi/common.ini
> 
> User=USER
> Restart=always
> Type=notify
> NotifyAccess=all
> StandardError=syslog
> 
> This requires two parameters, CODENAME and USER. Were the websites a bit 
> less 
> homogeneous, I could easily see them requiring more parameters. But let’s 
> start with two.
> 
> I created /etc/systemd/system/wsgi-.service.d/base.conf with the above 
> content, and I’m using %i for codename and %j for user. This lets me run 
> services as wsgi-USER@CODENAME.{service,socket} successfully, but has these

> problems:
> 
>  - Does not allow me to specify common [Install] directives (necessary for 
> .socket units) because systemd does not allow that in drop-ins
>  - Does not allow me to specify more than two parameters %i and %j
>  - Requires me to pre-create wsgi-USER@.{service,socket} files while taking
>    care for them not to be empty, lest systemd think they’re masked
>  - Is in general very hacky and unwieldy.
> 
> What good solution exists for this use case?
> 
> -- 
> WBR
> Roman.
> 
> 
> _______________________________________________
> systemd-devel mailing list
> systemd-devel@xxxxxxxxxxxxxxxxxxxxx 
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel 



_______________________________________________
systemd-devel mailing list
systemd-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/systemd-devel




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux