|
|
This section describes how you can create a service to start and stop Squore using the launcher script from the installation's bin
folder.
The examples below assume that:
Your Squore installation is located in /opt/Squoring/squore-server
You have created a user called squore to run the service, which is optional
After creating a service, you can configure it to launch Squore at boot, or you can start and stop Squore on your system by running the following commands:
sudo service squore start sudo service squore stop
Create a Squore service description file in /etc/init.d/squore
#!/bin/sh # # Squore Server Service # # chkconfig: 2345 20 80 # description: Squore launcher ### BEGIN INIT INFO # Provides: squore-server # Required-Start: # Required-Stop: # Should-Start: # Should-Stop: # Default-Start: # Default-Stop: # Short-Description: # Description: ### END INIT INFO # Source function library . /etc/rc.d/init.d/functions exec="/opt/Squoring/squore-server/bin/sqctl" user="squore" prog="squore" config="" [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog lockfile=/var/lock/subsys/$prog start() { #[ -x $exec ] || exit 5 #[ -f $config ] || exit 6 echo -n $"Starting $prog: " # if not running, start it up here, usually something like "daemon $exec" su $user -c "$exec start" #retval=$? #echo #[ $retval -eq 0 ] && touch $lockfile #return $retval } stop() { echo -n $"Stopping $prog: " # stop it here, often "killproc $prog" su $user -c "$exec stop" #retval=$? #echo #[ $retval -eq 0 ] && rm -f $lockfile #return $retval } restart() { su $user -c "$exec restart" } reload() { restart } force_reload() { restart } rh_status() { su $user -c "$exec status" } case "$1" in start) $1 ;; stop) $1 ;; restart) $1 ;; reload) $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) restart ;; *) echo $"Usage: $0 {start|stop|status|restart}" exit 2 esac exit $?
Make the service description file executable
chmod a+x /etc/init.d/squore
Add it to chkconfig
chkconfig --add squore
instruct chkconfig to start the service at boot
chkconfig squore on
Create a Squore service description file in /etc/systemd/system/squore.service
[Unit] Description=Squore Server Service After=network.target [Service] Type=forking User=squore ExecStart=/opt/Squoring/squore-server/bin/sqctl start ExecStop=/opt/Squoring/squore-server/bin/sqctl stop [Install] WantedBy=multi-user.target
Enable the service
systemctl enable squore.service