When the services under window are deployed to Linux, we typically use Mono.service to start the stop. The parameters are more and less useful. So here's a shell script.
Usage: MOA S1 start #启动
MOA S1 Stop # Stop
The following directory structure is required:
/opt/basepath/
s1/
Sample1.exe #服务1, file name not Limited
s2/
Sampleservice2.exe #服务2, file name not Limited
Daemon.d/#空目录, placing process identities
Moa #Shell脚本
#!/bin/bash# # Monosd Execute mono.service start stop. NET service, based on directory name. # For example: directory structure as follows, Monosd S1 start/stop#/opt/basedir/# /opt/basedir/s1#/opt/basedir/s1/xxxxx.exe# # # Chkconfig:- - -# Description:start or stop mono service by pathname# config:/etc/sysconfig/netconsole## Copyright -Qtong, inc.## BasedinchPart on a shell script by# Evlon<[email protected]> -- One- GenevaMonopath=/opt/mono/Binshname=$0SERVICENAME=$1#BASEPATH=/opt/${shname##*/} #BASEPATH=${shname%/*}basepath=$ (CD ' DirName $ '; pwd) daemonpath= $BASEPATH/daemon.dpath= $MONOPATH: $PATHRETVAL =0exefile= ' Find $ basepath/$SERVICENAME/-name *.exe ' exefile=${exefile##*/}usage () {Echo$"Usage: $ servicepathname {start|stop}" 1>&2RETVAL=2}start () {if[!-d $DAEMONPATH]; Then Echo$"directory does not exist $DAEMONPATH" 1>&2Exit3 fi if[!-D"$BASEPATH/$SERVICENAME"]; Then Echo$"directory does not exist $BASEPATH/$SERVICENAME" 1>&2Exit4 fi if["$EXEFILE"==""]; Then Echo$"could not find the executable file! Contents: $BASEPATH/$SERVICENAME/" 1>&2Exit5 fiMono-service-d: $BASEPATH/${servicename}-L: $DAEMONPATH/${servicename}d $EXEFILESleep 3 if[!-f $DAEMONPATH/${servicename}d]; Then Echo "PID:"`Cat$DAEMONPATH/${servicename}d '"Started" 1>&2 fi}stop () {if[!-d $BASEPATH/$SERVICENAME]; Then Echo$"directory does not exist $BASEPATH/$SERVICENAME" 1>&2Exit3 fi if[!-f $DAEMONPATH/${servicename}d]; Then Echo$"service is not running $BASEPATH/$SERVICENAME" 1>&2Exit5 fiPID=`Cat$DAEMONPATH/${servicename}d 'Kill`Cat$DAEMONPATH/${servicename}d 'Echo "PID: $PID stoped" 1>&2}restart () {Stop start} Case " $" inchstop) stop;; Start) Start; Restart|reload|force-reload) restart;; *) usage;;EsacExit $RETVAL
Control start-Stop of the mono service under Linux