Configuration

How to create a User-Defined Service for License/InTime Server?

255 views March 11, 2020 March 12, 2020 pohheng 0

Introduction:

This article shows how to create a user defined service for License/InTime Server in Windows and Linux environment. This will allow the service to start when the machine startup or rebooted. Do note that you will need extensive system administrator knowledge as it may cause conflict with other services.

Windows:

Make sure you have read and understand the article in https://support.microsoft.com/en-us/help/137890/how-to-create-a-user-defined-service before proceed.

Open a command prompt and type in the following.

Under Administrative Tools->Services, a new service with the name "License Server" will appear.

Run regedit in the command prompt to start a registry editor.

 

Under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<Service Name> in this example it is "License Server", create the similar structure. Save and reboot Windows.

Important Note: A stop command is provided to gracefully stop the service. Stopping the service from the Windows Services panel WILL NOT STOP the service.

C:\intimeserver> license_server.bat -stop

Linux:

Using rc.local file. For system that does not support Systemd/SystemV. Login with root account. Edit the file /etc/rc.local file.

# /bin/su -s /bin/bash -c 'cd <license installation path>; <license installation path>/license_server.sh' <user>

For system that uses Systemd. Login with root account. Edit the file /etc/systemd/system/<Service Name>.service. In this example the service name is "intimeserver".

[Unit]
Description=InTimeServer
After=network.target

[Service]
Type=forking
User=intimesvradmin
WorkingDirectory=/home/intimesvradmin/v3.0
ExecStart=/home/intimesvradmin/v3.0/start_server.sh
ExecStop=/home/intimesvradmin/v3.0/start_server.sh -stop
Restart=on-abort

[Install]
WantedBy=multi-user.target

Your service is all set up. Use the following commands to enable/stop/start/check status of the new service created.

# systemctl daemon-reload
# systemctl enable intimeserver
# systemctl stop intimeserver
# systemctl start intimeserver
# systemctl status intimeserver
Mar 11 9:12:48 centos7 start_server.sh[5091]: Starting InTime Server        [  OK   ]
Mar 11 9:12:48 centos7 start_server.sh[5091]: Starting License Server       [  OK   ]
Mar 11 9:12:48 centos7 start_server.sh[5091]: Starting ACL Server           [  OK   ]
Mar 11 9:12:49 centos7 start_server.sh[5091]: License server.lic            [  OK   ]
Mar 11 9:12:49 centos7 start_server.sh[5091]: License has started?          [  OK   ]
Mar 11 9:12:49 centos7 start_server.sh[5091]: License not expired?          [  OK   ]
Mar 11 9:12:49 centos7 start_server.sh[5091]: License Mac 12:34:56:78:90:AB [  OK   ]
Mar 11 9:12:49 centos7 start_server.sh[5091]: License features              [  OK   ]
Mar 11 9:12:49 centos7 start_server.sh[5091]: Admin portal can be accessed at http://192.168.1.2:39946/admin

For system that uses SystemV. Login with root account. Edit the file /etc/init.d/<Service Name>. In this example the service name is "intimeserver".

#!/bin/bash
#
# intimeserver InTime Server
#
# chkconfig: 345 70 30
# description: InTime Server
# processname: intimeserver

# Source function library.
. /etc/init.d/functions

RETVAL=0
prog="intimeserver"

# Declare variables
INTIMESERVER_DIR=/home/intimesvradmin/intimeserver/v3.0
INTIMESERVER_USER=intimesvradmin
APP=$INTIMESERVER_DIR/start_server.sh

start() {
        echo -n "Starting $prog: "
        runuser -l ${INTIMESERVER_USER} -c "cd ${INTIMESERVER_DIR}; ${APP}" < /dev/null
        return 0
}

stop() {
        runuser -l ${INTIMESERVER_USER} -c "${APP} -stop" < /dev/null
        return 0
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        stop
        start
        ;;
    *)
        echo "Usage: $prog {start|stop|restart}"
        exit 1
        ;;
esac
exit $RETVAL

Your service is all set up. Use the following commands to enable/stop/start the new service created.

# chkconfig --add intimeserver
# service intimeserver stop
# service intimeserver start

Applies to:

  • Windows Operating System
  • Linux Operating System

Knowledge Base ID: 202003061 - Last Review: Mar 06 2020 - Revision: 1.0