系统:CentOS7.0
移植过程中遇到的问题
执行service myserver start 的时候提示“没有权限”
处理方式:
chmod a+wrx /etc/init.d/myserver
执行“ln –s /etc/rc.d/init.d/sjhServer S97sjhServer”报异常目录不存在
处理方式:
ln –s /etc/rc.d/init.d/sjhServer S97sjhServer
说明:-s 后面多加一个空格
See mono-service version command
grep exec `type -p mono-service` | head -n 1
exec /usr/bin/mono $MONO_OPTIONS /usr/lib/mono/4.5/mono-service.exe $args
Source Page Orgin SourceCode
#!/bin/bash
#
# DREQPService : service for example
#
# chkconfig: 2345 97 92
# description: for test.
# processname: DREQPService
#
. /etc/rc.d/init.d/functions
SERVICE_NAME=DREQPServer
SERVICE_PATH=/usr/myfoder/camtest/service
SERVICE_ASSEMBLY=${SERVICE_PATH}/DREQPService.exe
SERVICE_LCK=/var/run/${SERVICE_NAME}.pid
start() {
echo -n $"Starting $SERVICE_NAME:"
daemon mono-service2 -l:$SERVICE_LCK $SERVICE_ASSEMBLY
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$SERVICE_NAME
return $RETVAL;
}
stop () {
echo -n $"Shutting down Mono Service $SERVICE_NAME:"
test -f $SERVICE_LCK && kill `cat $SERVICE_LCK`
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "Success stop";
else
echo "Error stop";
fi;
}
status() {
echo -n "Checking for Mono Service $SERVICE_NAME:"
test -f $SERVICE_LCK
RETVAL=$?
return $RETVAL;
}
pause() {
echo "Pausing Mono Service $SERVICE_NAME:"
test -f $SERVICE_LCK && kill -USR1 `cat $SERVICE_LCK`
RETVAL=$?
return $RETVAL;
}
cd $SERVICE_PATH
case "$1" in
start)
start;
RETVAL=$?;
;;
stop)
stop;
RETVAL=$?;
;;
pause)
pause;
RETVAL=$?
;;
condrestart)
stop;
start;
RETVAL=$?;
;;
restart|reload)
stop;
start;
RETVAL=$?;
;;
status)
status;
RETVAL=$?;
;;
*)
echo $"$SERVICE_NAME: Usage: < start | stop | pause | restart | reload | status >"
;;
esac;
exit $RETVAL;