Control start-Stop of the mono service under Linux

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.