一:安装Mono,此步骤参照官网
1:配置Yum仓库
#Centos 7
yum install yum-utils
rpm --import "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"
yum-config-manager --add-repo http://download.mono-project.com/repo/centos7/ 如若yum安装失败,可自己手动写repo文件,vim /etc/yum.repos.d/mono.repo' [mono]
name=mono
baseurl=http://download.mono-project.com/repo/centos/
enabled=1
gpgcheck=0
保存退出之后,再进行后续步骤!
#Centos
yum install yum-utils
rpm --import "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"
yum-config-manager --add-repo http://download.mono-project.com/repo/centos6/
2:安装mono
yum install mono-devel
#这里面是官网的安装说明,一般情况下安装devel就可以了!,安装所有,可以把对应的包名都加上! The package mono-devel should be installed to compile code. The package mono-complete should be installed to install everything - this should cover most cases of "assembly not found" errors. The package referenceassemblies-pcl should be installed for PCL compilation support - this will resolve most cases of "Framework not installed: .NETPortable" errors during software compilation. The package xsp should be installed for running ASP.NET applications.
二:配置windows程序的开机启动项
1: vim /etc/init.d/mfgRemotingServer,并输入以下内容
#!/bin/bash
#
#chkconfig:
#description:remotingservice
start()
{
#这里面的-l是指定lock文件,后面跟的是exe程序所在的绝对路径,可以通过mono-service命令查看帮助
mono-service -l:/root/remotingservice-lock /home/setquestion/Mfg.Setquestion.RemotingServer.exe
}
stop()
{
kill `cat /root/remotingservice-lock`
}
case "$1" in
start)
start
;; stop)
stop
;; restart)
stop
start
;;
*)
echo
$"Usage: $0 {start|stop|restart}"
exit
esac
2:执行时service mfgRemotingServer stop 会遇到 env: /etc/init.d/mfgRemotingServer: Permission denied,解决办法如下:
chmod +x /etc/init.d/mfgRemotingServer
service mfgRemotingServer stop
#加入到开机启动项
chkconfig --add mfgRemotingServer
chkconfig mfgRemotingServer on
3:mono-service的相关参数如下:
You must specify at least the assembly name Usage is: /usr/bin/mono-service [options] service -d:<directory> Working directory
-l:<lock file> Lock file (default is /tmp/<service>.lock)
-m:<syslog name> Name to show in syslog
-n:<service name> Name of service to start (default is first defined)
--debug Do not send to background nor redirect input/output
--no-daemon Do not send to background nor redirect input/output Controlling the service: kill -USR1 `cat <lock file>` Pausing service
kill -USR2 `cat <lock file>` Continuing service
kill `cat <lock file>` Ending service
PS:如果给为在安装和配置过程中有任何疑问,望留言。