Comment 11 for bug 1457464

Revision history for this message
Martin Pitt (pitti) wrote :

Of course, if you have a proper systemd unit that's always better. But some suggestions:

> [Unit]
> Description=the system-wide CouchDB instance

Please drop the "the" and start with a capital letter for some consistency.

> After=network-online.target

Is that really necessary? I. e. couchdb doesn't get along with new network
interfaces coming up after boot? Note that this is mostly a workaround, and
won't do anything if you e. g. hotplug/enable/connect to a new network during
runtime.

If you need it, you also need a corresponding Wants=network-online.target

> [Service]
> Type=simple

That's the default, you can omit this.

> ExecStartPre=/bin/mkdir -p /run/couchdb
> ExecStartPre=/bin/chown couchdb:couchdb /run/couchdb

Replace this with RuntimeDirectory=couchdb (see man systemd.exec)

> ExecStart=/bin/su couchdb -c /usr/bin/couchdb

Don't use su, that'll go through the PAM stack etc. Use this instead:

User=couchdb
ExecStart=/usr/bin/couchdb

> ExecStopPost=/bin/rm -rf /run/couchdb

Handled automatically by RuntimeDirectory, so drop.

> Restart=on-failure
>
> [Install]
> WantedBy=multi-user.target

So, all in all:

[Unit]
Description=System-wide CouchDB instance
Wants=network-online.target
After=network-online.target

[Service]
RuntimeDirectory=couchdb
User=couchdb
ExecStart=/usr/bin/couchdb
Restart=on-failure

[Install]
WantedBy=multi-user.target