Long story short, systemd is a Service Control Manager present in CentOS 7, Red Hat 7, SUSE v12 and lately in Debian and Ubuntu Linux distributions. Previously, Linux distros used System V based rc files or xinetd for service management but it seems to be greatly limited, so all the big Linux distributions are moving towards systemd.
In systemd, you don’t use shell script commands to start and stop your service, rather you need to build a “service” file with specific syntax that gives directives to systemd to manage your service.
A few directories to be aware of:
|Directory for your service file.
|Directory for your service’s Environment file.
Create service file for Informix
You will need to created the following file, usually called informix.service in the /usr/lib/systemd/system/ directory.
Description=Informix IDS Database Server
The [Unit] section is an identifier.
The [Service] section is where your systemd directives go.
The [Install] section controls when your program is run…in this case, “multi-user.target” refers to runlevel 3, just like the old rc3.d did.
EnvironmentFile is the file where any Environmental Variables required by Informix to run (ie, INFORMIXDIR) are defined.
ExecStart is the command that starts your service. For Informix that’s the program oninit.
ExecStop is the command that stops your service. For Informix that’s onmode.
RemainAfterExit allows systemd to consider service started properly even oninit program exists. You need this parameter to be ser because Informix uses some tricks in their starting process, so Type=forking can’t be used.
The filenames and program names MUST be absolute pathnames. Even though I defined Environment Variables in my EnvironmentFile, I couldn’t get them to work in the pathnames for the ExecStart or ExecStop programs.
Create configuration file for Informix service
Since oninit won’t run unless it can find some things in the Environment, I wrote a small file called informix_service (you can name it anything you want) and placed it in the /etc/sysconfig/ directory. Here is my informix_service EnvironmentFile:
# informix.service environmental variables
Of course, substitute your directory names and file names as needed.
Manage Informix service
Start de informix service:
# systemctl start informix
You can use onstat to see if it started, or run:
# systemctl status informix
To stop the informix service:
# systemctl stop informix
Start the service at boot:
# systemctl enable informix
ln -s '/etc/systemd/system/informix.service' '/etc/systemd/system/multi-user.target.wants/informix.service'
If you want to disable start the service at boot:
# systemctl disable informix
If everything runs okay manually, reboot your system after enabling the service. Hopefully, everything will work for you.