我对Linux很新,而且我正在把我的服务器从Windows切换到Centos 6.3。 我写了一个小型的UDP服务器。 UDP服务器是用C#编写的,现在我用它来和Mono一起使用Linux。 它运行的很好,当我这样运行时:
/opt/mono/bin/mono /root/MySoft/UDPServer.exe "$@"
我如何自动运行 – 计算机统计信息? (以windows的forms表示:windows-service)
我试图创build一个启动文件,并把它放到/etc/init.d但它没有工作
我这样的解决scheme是安装和使用supervisord。
Supervisord是一个python进程pipe理器,从发行版的软件包中可以很容易地安装,而且configuration简单。 您只需为可执行文件添加一个简单的configuration文件,Supervisor会负责启动它,捕获输出,并且(可选)在进程失败时重新启动它。
一个configuration示例如下所示:
[program:udp_server] user = <username> command = /opt/mono/bin/mono /root/MySoft/UDPServer.exe "$@" stdout_logfile = /var/log/udp_server-stdout.log stdout_logfile_maxbytes = 10MB stdout_logfile_backups = 5 stderr_logfile = /var/log/udp_server-stderr.log stderr_logfile_maxbytes = 10MB stderr_logfile_backups = 5
此外,这个解决scheme工作:
我添加了一行文本/opt/mono/bin/mono /root/MySoft/UDPServer.exe "$@" &到/etc/rc.d/rc.local