5

I have a systemd service which checks external media is mounted on starting.

[Unit]
Description=My App
ConditionPathIsMountPoint=/mnt/sdcard

[Service]
WorkingDirectory=/opt/myapp
ExecStartPre=+/opt/myapp/bin/pre.sh
ExecStart=/opt/myapp/bin/myapp
ExecStop=/bin/kill -INT ${MAINPID}
ExecReload=/bin/kill -INT ${MAINPID} && /opt/myapp/bin/myapp
Restart=always
RestartSec=5
User=user
Group=user

[Install]
WantedBy=multi-user.target mnt-sdcard.mount

I would like to wait myapp starting until /mnt/sdcard will be mounted. But this service does not work well. When mount the media is delayed, the systemd throws start condition failed and does not retry.

# systemctl status myapp
● myapp.service - My App
   Loaded: loaded (/etc/systemd/system/myapp.service; enabled; vendor preset: enabled)
   Active: inactive (dead)
Condition: start condition failed at Wed 2021-01-27 14:22:31 JST; 2h 35min ago
            ConditionPathIsMountPoint=/mnt/sdcard was not met

How can I make retry starting when start condition failed?

2 Answers 2

0

in your prestart script have it check if the external media is mounted in a loop with delay

0

If the sdcard is supposed to be mounted on boot, you can add below instead of the condition.

Requires=mnt-sdcard.mount

Remove mnt-sdcard.mount from WantedBy. Not sure what it does.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .