Introduction
This document describes how to create service files for init.d or Systemd for EFM (Edge Fog Processing Module).
Prerequisites
Requirements
Cisco recommends that you have knowledge of Linux.
Components Used
This document is not restricted to specific software and hardware versions.
The information in this document was created from the devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If your network is live, ensure that you understand the potential impact of any command.
Configure
The EFM installation package does not contain service files for init.d or Systemd out of the box.
Here you can find a simple example to create a service file.
For init.d
[root@cen7 ~]# cat /etc/init.d/efm
#!/bin/bash
# EFM init script.
EFM_HOME="/opt/cisco/kinetic/efm_server"
EFM_USER="EFM"
case "$1" in
'start')
echo "Starting EFM as $EFM_USER"
sleep 2
su -c "$EFM_HOME/bin/daemon.sh start" $EFM_USER
;;
'stop')
echo "Stopping EFM as $EFM_USER"
su -c "$EFM_HOME/bin/daemon.sh stop" $EFM_USER
;;
*)
# usage
echo "usage: $0 start|stop"
exit 1
;;
esac
Ensure that you adjust the environment variables to match your environment: EFM_HOME and EFM_USER.
After the file is created, ensure that it is marked as executable.
For Systemd
[root@cen7 ~]# cat /etc/systemd/system/efm.service
[Unit]
Description=EFM
After=network.target
[Service]
Type=forking
User=EFM
WorkingDirectory=/opt/cisco/kinetic/efm_server/
ExecStart=/opt/cisco/kinetic/efm_server/bin/daemon.sh start
Restart=no
GuessMainPID=yes
[Install]
WantedBy=multi-user.target
Ensure that you adjust the configurationvariables to match your environment: User=.
After the service file is created, ensure that you update the daemon files in systemd:
[root@cen7 ~]# systemctl daemon-reload
Verify
To verify if the scripts/service file work as expected, you can try to start and stop the service:
For init.d
[root@cen7 ~]# /etc/init.d/efm start
Starting EFM as EFM
DSA Version: 1.1.2
DGLux5 Build: r7914
DGLux Server Build: 1230
Verifying Environment...
Verifying Configuration...
Server Started. (pid: 3790)
...
[root@cen7 ~]# /etc/init.d/efm stop
Stopping EFM as EFM
Server Stopped.
For Systemd
[root@cen7 ~]# systemctl start efm
[root@cen7 ~]#
[root@cen7 ~]# systemctl status efm
● efm.service - EFM
Loaded: loaded (/etc/systemd/system/efm.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2018-04-23 17:01:22 CEST; 4s ago
Process: 5725 ExecStart=/opt/cisco/kinetic/efm_server/bin/daemon.sh start (code=exited, status=0/SUCCESS)
Main PID: 5737 (dart)
CGroup: /system.slice/efm.service
├─5737 /opt/cisco/kinetic/dart-sdk/bin/dart --old_gen_heap_size=16 --new_gen_semi_max_size=2 /opt/cisco/kinetic/efm_server/bin/server_watcher.dart --log-file=logs/dglux_server.log --manager-port...
├─5746 /opt/cisco/kinetic/dart-sdk/bin/dart -Ddglux.server.watcher=true -Ddslink.runtime.manager=true -Ddglux.server.log=/opt/cisco/kinetic/efm_server/logs/dglux_server.log --old_gen_heap_size=1...
├─5785 java -classpath /opt/cisco/kinetic/efm_server/dslinks/Alarms/lib/dslink-0.18.3.jar:/opt/cisco/kinetic/efm_server/dslinks/Alarms/lib/jcommander-1.48.jar:/opt/cisco/kinetic/efm_server/dslin...
├─5788 /opt/cisco/kinetic/dart-sdk/bin/dart bin/run.dart --name DQL --log info --broker http://127.0.0.1:35294/conn --token DpKbOMophIePrJvdGpXyt1H0RpcM8g8hkPXyDqaEIVwIQLzF
├─5794 java -classpath /opt/cisco/kinetic/efm_server/dslinks/H2_DB/lib/jcommander-1.48.jar:/opt/cisco/kinetic/efm_server/dslinks/H2_DB/lib/commons-dbcp2-2.1.1.jar:/opt/cisco/kinetic/efm_server/d...
├─5801 /opt/cisco/kinetic/dart-sdk/bin/dart run.dart --name dataflow --broker http://127.0.0.1:35294/conn --token nkH3JEA12v82GthaCsb9IfAL0iMWJNaYtiuRA7ruB28T7jdf
├─5803 /opt/cisco/kinetic/dart-sdk/bin/dart bin/run.dart --name System --linux_use_free_command true --offset_memory_disk_cache true --broker http://127.0.0.1:35294/conn --token OSkQvkA3diq3OLtw...
└─5826 java -d64 -Djava.library.path=/opt/cisco/kinetic/efm_server/dslinks/parstream-dsa-link/lib/centos7 -classpath lib/bcprov-jdk15on-1.51.jar:lib/cisco-parstream-jdbc-5.0.0.jar:lib/commons-cs...
Apr 23 17:01:22 cen7 systemd[1]: Starting EFM...
Apr 23 17:01:22 cen7 daemon.sh[5725]: DSA Version: 1.1.2
Apr 23 17:01:22 cen7 daemon.sh[5725]: DGLux5 Build: r7914
Apr 23 17:01:22 cen7 daemon.sh[5725]: DGLux Server Build: 1230
Apr 23 17:01:22 cen7 daemon.sh[5725]: Verifying Environment...
Apr 23 17:01:22 cen7 daemon.sh[5725]: Verifying Configuration...
Apr 23 17:01:22 cen7 daemon.sh[5725]: Server Started. (pid: 5737)
Apr 23 17:01:22 cen7 systemd[1]: Started EFM.
[root@cen7 ~]#
[root@cen7 ~]# systemctl stop efm
As you can see, the EFM processes get started under the user you defined in the service files and everything gets cleaned up after it is requested to stop the services.
Troubleshoot
In case you experience issues to start, check these:
- Configurable parameters in the init.d or Systemd service file (user, paths)
- For SystemD: The output of systemctl status efm
- The output of journalctl --unit=efm