Creating and configuring system daemon

Creating and configuring CouchDB system daemon inside Fedora Linux

In previous chapter we are installed CouchDB instance from sources. Now we are should to make it controllable on system level by creating system daemon that will start, stops and checks state of database. Fedora 25 uses SystemD init daemon to control other system daemons. So, let's create it.

Go to the path with configuration files of system daemons:
cd /etc/systemd/system/
and create new one:
sudo nano ./couchdb.service
Next paste this configuration:
[Unit]
Description=Couchdb service
After=syslog.target
After=network.target

[Service]
Type=simple
User=root
ExecStart=/opt/couchdb/bin/couchdb -o /dev/stdout -e /dev/stderr
Restart=always
KillMode=mixed
KillSignal=SIGINT

TimeoutSec=300

[Install]
WantedBy=multi-user.target
Enable daemon
sudo systemctl enable couchdb.service
And start it
sudo systemctl start couchdb.service
Check state
sudo systemctl status couchdb.service
You should see listing like this:
● couchdb.service - Couchdb service
   Loaded: loaded (/etc/systemd/system/couchdb.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2017-05-29 16:26:20 EEST; 20min ago
 Main PID: 21192 (beam.smp)
    Tasks: 29 (limit: 4915)
   CGroup: /system.slice/couchdb.service
           ├─21192 /opt/couchdb/bin/../erts-8.3.2/bin/beam.smp -K true -A 16 -Bd -- -root /opt/couchdb/bin/.. -progname couchdb -- -home /root -- -boot /opt/couchdb/bin/../releases/2.0.0/couchdb -name couchdb@localhost -setcookie monster -kernel error_logger silent -sasl sasl_error_logger false -noshell -noinput -config /opt/couchdb/bin/../releases/2.0.0/sys.config
           ├─21206 /opt/couchdb/bin/../erts-8.3.2/bin/epmd -daemon
           ├─21225 erl_child_setup 1024
           ├─21231 sh -s disksup
           ├─21233 /opt/couchdb/bin/../lib/os_mon-2.4.2/priv/bin/memsup
           ├─21234 /opt/couchdb/bin/../lib/os_mon-2.4.2/priv/bin/cpu_sup
           ├─21236 inet_gethost 4
           └─21237 inet_gethost 4
If this is just installed instance of CouchDB, then you can see in the end of listing few errors. It is because we haven't configured type of database(single-node or cluster) and haven't created admin. Just ignore it. We are will configure it in next chapters.

Comments

Popular Posts