Managing Informix Services in systemd

Following my blog series about how to create systemd services related to Informix, I’m going to use this post to summarize examples about how to create systemd units for all the Informix services.
Systemd is the “not so new” init process used for the main Linux Operating Systems like, Red Hat, CentOS, Fedora, Ubuntu or Suse. You can get more information about Systemd at https://en.wikipedia.org/wiki/Systemd
This post assumes you have knowledge about how to create and configure systemd services. You can also read my previous post about how to create a service for Informix IDS: Automatize Informix start-stop with systemd

Remember there are a basic tips to enable and start services:

  1. Create de file defining unit in systemd
  2. Execute “systemctl daemon-reload”
  3. Start service. E.G. systemctl start informixHQ.service
  4. Enable service for starting when system starts: systemctl enable informixHQ.service

you will need to configure the service files to accomplish your current configuration.

Create Systemd Service for Informix HQ Server

sudo vim /etc/systemd/system/informixHQ.service

[Unit]
Description=Informix HQ Server
Wants=network-online.target
After=network.target network-online.target

[Service]
Type=simple
WorkingDirectory=/home/informix/hq
ExecStart=/bin/sh -a -c '../jvm/jre/bin/java -jar informixhq-server.jar informixhq-server.properties'
User=root
Restart=on-failure
RestartSec=30

[Install]
WantedBy=multi-user.target

Line “Wants=network-online.target” implies that Informix HQ Service should wait for network to be online to start.
Line “WorkingDirectory” configure folder where systemd enters before starting commands.
Line “ExecStart”. Here we make a trick. We use absolute path for /bin/sh to execute a relative path to access Java.
Line “User=root”. Even it should be a non-root user like informix. We use root as user in this example to allow configure service port to privileged port like 80 or 443. I you keep default unprivileged port 8080, here it’s better to use informix user.

Create Systemd Service for Informix HQ Agent

sudo vim /etc/systemd/system/informixHQagent.service

[Unit]
Description=Informix HQ Agent
After=informix.service

[Service]
Type=simple
WorkingDirectory=/home/informix/hq
ExecStart=/bin/sh -a -c '../jvm/jre/bin/java -jar informixhq-agent.jar informixhq-agent.properties'
User=informix
Restart=on-failure
RestartSec=30

[Install]
WantedBy=multi-user.target

Create Systemd Service for Informix IDS Server

sudo vim /etc/systemd/system/informix.service

[Unit]
Description=Informix IDS
Documentation=file:/home/informix/release/en_us/0333 http://www.ibm.com/software/data/informix/library.html
OnFailure=notification-zabbix@%n.service
Wants=network-online.target
After=network.target network-online.target

[Service]
Type=forking
User=informix
Group=informix
#EnvironmentFile=/etc/profile.d/informix.sh
Environment="ENV_FILE=/etc/profile.d/informix.sh"
ExecStart=/bin/sh -a -c 'source $ENV_FILE && oninit -w -U $INFORMIXSERVER'
ExecStop=/bin/sh -a -c 'source $ENV_FILE && $INFORMIXDIR/bin/onmode -uky'
ExecStartPost=-/bin/sh -a -c 'source $ENV_FILE; if [ -f $INFORMIXDIR/autostart.sql ]; then $INFORMIXDIR/bin/dbaccess - $INFORMIXDIR/autostart.sql >>/tmp/autostart_${INFORMIXSERVER}.log 2>&1; fi'
ExecStartPost=-/bin/sh -a -c 'source $ENV_FILE; if [ -f $INFORMIXDIR/autostart.sql ]; then mv $INFORMIXDIR/autostart.sql $INFORMIXDIR/autostart_executed.sql; fi'
Restart=on-failure
RestartSec=60
#TimeoutStartSec=120

[Install]
WantedBy=multi-user.target

Create Systemd Service for Informix IWA

sudo vim /etc/systemd/system/informix-iwa.service

[Unit]
Description=Informix IWA
Documentation=http://www.ibm.com/software/data/informix/library.html
Wants=network-online.target
After=network.target network-online.target

[Service]
Type=forking
Environment="ENV_FILE=/etc/profile.d/informix.sh" 
ExecStart=/bin/sh -a -c 'source $ENV_FILE && /home/informix/IWA/bin/ondwa start' 
ExecStop=/bin/sh -a -c '/home/informix/IWA/bin/ondwa stop -f' 
Restart=on-failure 
RestartSec=120 
#TimeoutStartSec=300

[Install]
WantedBy=multi-user.target
Published
Categorized as Blog

By Vicente Salvador

Board member since 2014, a user since 1989 and Informix fan. I'am software architect which allow me to combine technical and business skills.

1 comment

  1. Thank you very much for the previous articles on this, that has made my life much easier (or, at least, not as interrupted during sleep…)

Comments are closed.