Control the start and stop of the mono service in Linux

Source: Internet
Author: User

Control the start and stop of the mono service in Linux
When the services in windows are deployed to Linux, we generally use Mono. service to start and stop. It is not easy to use because there are many parameters. So there is a Shell script. Usage: moa s1 start # start moa s1 stop # The following directory structure is required to stop:

/Opt/basepath/s1/sample1.exe # Service 1. The file name is not limited to s2/sampleservice2.exe # Service 2. The file name is not limited to daemon. d/# Empty directory, put the process identifier moa # Shell script #! /Bin/bash # Mono is executed by monosd. service starts and stops. net service, according to the directory name. # For example, when the directory structure is as follows, monosd s1 start/stop #/opt/basedir/s1 #/opt/basedir/s1/xxxxx.exe ### chkconfig: -50 50 # description: start or stop mono service by pathname # config:/etc/sysconfig/netconsole # Copyright 2015 Qtong, Inc. # Based in part on a shell script by # evlon <[email protected]> 2015-11-02MONOPATH =/opt/mono/binSHNAME = $0 SERVIC ENAME = $1 # BASEPATH =/opt/$ {SHNAME ### */} # BASEPATH =$ {SHNAME %/*} BASEPATH = $ (cd 'dirname $0 '; pwd) DAEMONPATH = $ BASEPATH/daemon. dPATH = $ MONOPATH: $ PATHRETVAL = 0 EXEFILE = 'Find $ BASEPATH/$ SERVICENAME/-name *. exe 'exefile =$ {EXEFILE ### */} usage () {echo $ "Usage: $0 servicePathName {start | stop} "1> & 2 RETVAL = 2} start () {if [! -D $ DAEMONPATH]; then echo $ "the directory does not exist $ DAEMONPATH" 1> & 2 exit 3 fi if [! -D "$ BASEPATH/$ SERVICENAME"]; then echo $ "the directory does not exist $ BASEPATH/$ SERVICENAME" 1> & 2 exit 4 fi if ["$ EXEFILE" = ""]; then echo $ "the executable file cannot be found! Directory: $ BASEPATH/$ SERVICENAME/"1> & 2 exit 5 fi mono-service-d: $ BASEPATH/$ {SERVICENAME}-l: $ DAEMONPATH/$ {SERVICENAME} d $ EXEFILE sleep 3 if [! -F $ DAEMONPATH/$ {SERVICENAME} d]; then echo "PID: "'cat $ DAEMONPATH/$ {SERVICENAME} d'" Started "1> & 2 fi} stop () {if [! -D $ BASEPATH/$ SERVICENAME]; then echo $ "the directory does not exist $ BASEPATH/$ SERVICENAME" 1> & 2 exit 3 fi if [! -F $ DAEMONPATH/$ {SERVICENAME} d]; then echo $ "the service is not running $ BASEPATH/$ SERVICENAME" 1> & 2 exit 5 fi PID = 'cat $ DAEMONPATH/$ {SERVICENAME} d 'kill' cat $ DAEMONPATH/$ {SERVICENAME} d 'echo "PID: $ PID Stoped "1> & 2} restart () {stop start} case" $2 "in stop) stop; start) start; restart | reload | force-reload) restart; *) usage; esacexit $ RETVAL

 


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.