Skip to content

Commit

Permalink
add systemd unit file
Browse files Browse the repository at this point in the history
Update the spec file with the rpm macro to put the unit file
in the system-wide unit file directory based on:

    [root@1713bbf19a0b /]# rpmbuild --eval '%{_unitdir}'
    /usr/lib/systemd/system

Allow user to create a drop directory to specify options
via environment variables.

Resolves #12.
  • Loading branch information
jumanjiman committed Apr 26, 2016
1 parent 3120628 commit f0d6cfa
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,28 @@ If you have a well phrased question that might benefit others, consider asking i
## Examples:
Please look in the [examples/](examples/) folder for more examples!

## Systemd:
See [`misc/mgmt.service`](misc/mgmt.service) for a sample systemd unit file.
This unit file is part of the RPM.

To specify your custom options for `mgmt` on a systemd distro:

```bash
sudo mkdir -p /etc/systemd/system/mgmt.service.d/

cat > /etc/systemd/system/mgmt.service.d/env.conf <<EOF
# Environment variables:
MGMT_SEED_ENDPOINT=http://127.0.0.1:2379
MGMT_CONVERGED_TIMEOUT=-1
MGMT_MAX_RUNTIME=0
# Other CLI options if necessary.
#OPTS="--max-runtime=0"
EOF

sudo systemctl daemon-reload
```

## Documentation:
Please see: [DOCUMENTATION.md](DOCUMENTATION.md) or [PDF](https://pdfdoc-purpleidea.rhcloud.com/pdf/https://github.com/purpleidea/mgmt/blob/master/DOCUMENTATION.md).

Expand Down
1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ Let us know if you're working on one of the items.
## Other
- [ ] implement noop functionality [bug](https://github.com/purpleidea/mgmt/issues/21) [:heart:](https://github.com/purpleidea/mgmt/labels/mgmtlove)
- [ ] better error/retry handling
- [ ] mgmt systemd service file [bug](https://github.com/purpleidea/mgmt/issues/12) [:heart:](https://github.com/purpleidea/mgmt/labels/mgmtlove)
- [ ] deb package target in Makefile
- [ ] reproducible builds
- [ ] add your suggestions!
13 changes: 13 additions & 0 deletions misc/mgmt.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Run mgmt configuration management
Documentation=https://github.com/purpleidea/mgmt/
After=systemd-networkd.service
Requires=systemd-networkd.service

[Service]
ExecStart=/usr/bin/mgmt run ${OPTS}
RestartSec=5s
Restart=always

[Install]
WantedBy=multi-user.target
3 changes: 3 additions & 0 deletions spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ rm -rf %{buildroot}
# _datadir is typically /usr/share/
install -d -m 0755 %{buildroot}/%{_datadir}/__PROGRAM__/
cp -a AUTHORS COPYING COPYRIGHT DOCUMENTATION.md README.md THANKS examples/ %{buildroot}/%{_datadir}/__PROGRAM__/
mkdir -p %{buildroot}/%{_unitdir}/
install -pm 0644 misc/__PROGRAM__.service %{buildroot}/%{_unitdir}/

# install the binary
mkdir -p %{buildroot}/%{_bindir}
Expand All @@ -58,6 +60,7 @@ install -m 0644 misc/example.conf %{buildroot}%{_sysconfdir}/__PROGRAM__/__PROGR
%{_datadir}/__PROGRAM__/*
%{_bindir}/__PROGRAM__
%{_sysconfdir}/__PROGRAM__/*
%{_unitdir}/__PROGRAM__.service

# this changelog is auto-generated by git log
%changelog

0 comments on commit f0d6cfa

Please sign in to comment.