Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Formula try do start/stop multiinstance service - it won't work #65

Open
unix196 opened this issue Jan 13, 2021 · 1 comment
Open
Labels
bug Something isn't working

Comments

@unix196
Copy link

unix196 commented Jan 13, 2021

https://www.stevenrombauts.be/2019/01/run-multiple-instances-of-the-same-systemd-unit/
I needed to start multiple instances of a single unit automatically with systemd, write config like this:

systemctl cat browser.target
[Install]
WantedBy=multi-user.target

[Unit]
After=network.target
Description=Chromium target
[email protected]
[email protected]
[email protected]

systemctl cat [email protected]
[Service]
ExecStart=some_command
Group=chromium
...
Type=simple

[Unit]
After=network.target
Description=Browser runner %i
PartOf=browser-runner.target

Multiinstance unit service didn't support enable/disable or start/stop (it's like a template). Start/stop or enable/disable I can only with target or explicitly given instances:

systemctl  status [email protected]
systemctl  is-enabled browser-runner.target

systemctl  status [email protected]
Failed to get properties: Unit name [email protected] is missing the instance name.

systemctl  status [email protected][email protected] - Browser runner 1
   Loaded: loaded (/etc/systemd/system/[email protected]; static; vendor preset: enabled)

In this code state try start start/stop only for service unittypes, but In my example it's need doing and for target unittypes. I think can be done like this:

-      {% if unittype == 'service' %}
-        {% set activation_status = unitconfig.status if unitconfig.status is defined and unitconfig.status == 'start' else 'stop' %}
+      {% if unittype == 'service' or unittype == 'target' %}
+      {% if unitconfig.status is defined %}
        {% set activation_status = unitconfig.status if unitconfig.status == 'start' else 'stop' %}
systemd_systemd_units_activate_or_deactivate_{{ unit }}_{{ unittype }}:
  cmd.wait:
    - name: systemctl {{ activation_status }} {{ unit }}.{{ unittype }}
...
+     {% endif %}

In pillar explicitly define status variable.

@unix196 unix196 added the bug Something isn't working label Jan 13, 2021
@B1ue-W01f
Copy link

Also timer units would be ideal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants