Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

50%
+0 −0
Q&A How to create systemd unit that depends on a website being up?

To make your example work, you should add Type=oneshot and RemainAfterExit=true to the [Service] section. This way the unit won't be considered active until the curl has actually succeeded, and ei...

posted 1y ago by Iizuki‭

Answer
#1: Initial revision by user avatar Iizuki‭ · 2023-10-10T11:18:54Z (about 1 year ago)
To make your example work, you should add [`Type=oneshot`](https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type=) and [`RemainAfterExit=true`](https://www.freedesktop.org/software/systemd/man/systemd.service.html#RemainAfterExit=) to the `[Service]` section.
This way the unit won't be considered active until the curl has actually succeeded, and either won't go inactive afterwards.




However, this is somewhat unorthodox way of going about it. One would expect `website.service` to really manage the service process, and not be just a proxy for it (using curl in this case).

Instead you could just add the unit actually managing the server process as a dependency to your other units. E.g. on Ubuntu your website might be running on Apache:
```systemd
[Unit]
Description=A thing requiring the website
Requisite=apache2.service
After=apache2.service

[Service]
...
```
[Requisite](https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Requisite=) makes starting the unit simply fail if Apache isn't running. It won't try to start it (as unwittingly starting web services can lead to security issues).