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

How to run in a systemd service? #27

Closed
RumenBlack84 opened this issue Aug 23, 2023 · 2 comments
Closed

How to run in a systemd service? #27

RumenBlack84 opened this issue Aug 23, 2023 · 2 comments

Comments

@RumenBlack84
Copy link

RumenBlack84 commented Aug 23, 2023

I am running the linux version of this software

Due to how the program is started it is difficult to run as a systemd service.
Since the script iventoy.sh starts the iventoy process they have different names and as far as I can tell if using systemd the script cannot be used to start the process

From reading the start script I have been able to determine that as root this will start it.

cd /opt/iventoy/
env IVENTOY_API_ALL=1 IVENTOY_AUTO_RUN=1 /opt/iventoy/lib/iventoy

This works when run manually at the command line.

However If I try to run this as a service the process will not successfully start

[Unit]
Description=Iventoy Service
After=network.target

[Service]
Type=simple
Environment="IVENTOY_API_ALL=1"
Environment="IVENTOY_AUTO_RUN=1"
WorkingDirectory=/opt/iventoy
ExecStart=/opt/iventoy/lib/iventoy
Restart=always

[Install]
WantedBy=default.target

No success with this variation either.

[Unit]
Description=Iventoy Service
After=network.target

[Service]
Type=simple
WorkingDirectory=/opt/iventoy
ExecStart=env IVENTOY_API_ALL=1 IVENTOY_AUTO_RUN=1 /opt/iventoy/lib/iventoy
Restart=always

[Install]
WantedBy=default.target

Below is the output I get from running sudo systemctl status iventoy.service

× iventoy.service - Iventoy Service
     Loaded: loaded (/etc/systemd/system/iventoy.service; disabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Wed 2023-08-23 17:12:47 UTC; 952ms ago
    Process: 1438 ExecStartPre=/bin/bash -c cd /opt/iventoy (code=exited, status=0/SUCCESS)
    Process: 1439 ExecStart=/opt/iventoy/lib/iventoy (code=exited, status=127)
   Main PID: 1439 (code=exited, status=127)
        CPU: 3ms

Aug 23 17:12:47 iventoy systemd[1]: iventoy.service: Scheduled restart job, restart counter is at 5.
Aug 23 17:12:47 iventoy systemd[1]: Stopped Iventoy Service.
Aug 23 17:12:47 iventoy systemd[1]: iventoy.service: Start request repeated too quickly.
Aug 23 17:12:47 iventoy systemd[1]: iventoy.service: Failed with result 'exit-code'.
Aug 23 17:12:47 iventoy systemd[1]: Failed to start Iventoy Service.

I definitely feel a product such as iventoy needs a way to be run as a service like this to ensure reliability.

@devome
Copy link

devome commented Aug 26, 2023

[Unit]
Description = iVentoy iPXE Server
Requires = network-online.target
After    = network-online.target
Wants    = network-online.target

[Service]
Type = forking
User = root
Group = root
WorkingDirectory = /opt/iventoy
ExecStart = /opt/iventoy/iventoy.sh -R start
ExecStop = /opt/iventoy/iventoy.sh stop

[Install]
WantedBy = multi-user.target

@RumenBlack84
Copy link
Author

Thanks that worked great for me! I did add
Restart=always
to the service section however to ensure if the pid dies it starts again.
Tested it by killing the iventoy pid and it successfully starts again with your settings.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants