❶ mono鏄浠涔堟剰鎬
mono鏄浠涔堟剰鎬濓細鏄鍗曞0閬撶殑錛屾剰鎸囧崟澹伴亾褰曢煶(鎴栨斁闊)緋葷粺銆
鎷撳睍璧勬枡錛
鍗曞0閬撶殑浠嬬粛錛
1銆佸崟澹伴亾錛圫ingle channel錛夋槸澹伴煶澶嶅埗褰㈠紡錛屾槸鎸囧彧鏈夊崟涓澹伴亾鐨勯煶棰戞枃浠剁О涔嬩負鍗曞0閬撱備竴涓澹伴煶閫氶亾錛岀敤涓涓浼犲0鍣ㄦ嬀鍙栧0闊籌紝鐢ㄤ竴涓鎵澹板櫒榪涜屾斁闊崇殑榪囩▼錛岀О涔嬩負鍗曞0閬撱傚崟澹伴亾鏄鎸囨妸鏉ヨ嚜涓嶅悓鏂逛綅鐨勯煶棰戜俊鍙鋒販鍚堝悗緇熶竴鐢卞綍闊沖櫒鏉愭妸瀹冭板綍涓嬫潵錛屽啀鐢變竴鍙闊崇辮繘琛岄噸鏀俱
2銆佸湪鍗曞0閬撶殑闊沖搷鍣ㄦ潗涓錛屼綘鍙鑳芥劅鍙楀埌澹伴煶銆侀煶涔愮殑鍓嶅悗浣嶇疆鍙婇煶鑹層侀煶閲忕殑澶у皬錛岃屼笉鑳芥劅鍙楀埌澹伴煶浠庡乏鍒板彸絳夋í鍚戠殑縐誨姩銆傛墍閲嶆挱鏃剁殑鏁堟灉鐩稿逛簬鐪熷疄鐨勮嚜鐒跺0鏉ヨ達紝鏄綆鍗曞寲鐨勶紝鏄澶辯湡浜嗙殑銆傚湪鐢佃嗗箍鎾涓錛屽崟澹伴亾浼撮煶璐ㄩ噺嬈犱匠錛岀壒鍒鏄閬囧埌浼樺娍鐨勬枃鑹鴻妭鐩錛屽挨鍏舵槸鐜板満鐩存挱楂樻按騫崇殑闊充箰琛ㄦ紨鏃跺氨鏄懼緱閫婅壊涓嶅皯銆
5銆佸崟澹伴亾鏄姣旇緝鍘熷嬬殑澹伴煶澶嶅埗褰㈠紡錛屾棭鏈熺殑澹板崱閲囩敤鐨勬瘮杈冩櫘閬嶃傚綋閫氳繃涓や釜鎵澹板櫒鍥炴斁鍗曞0閬撲俊鎮鐨勬椂鍊欙紝鎴戜滑鍙浠ユ槑鏄炬劅瑙夊埌澹伴煶鏄浠庝袱涓闊崇變腑闂翠紶閫掑埌鎴戜滑鑰蟲湹閲岀殑銆傝繖縐嶇己涔忎綅緗鎰熺殑褰曞埗鏂瑰紡鏄寰堣惤鍚庣殑銆
❷ 濡備綍鍒╃敤mono鎶.net windows service紼嬪簭榪佺Щ鍒發inux涓
鐩鐨勶細浣跨敤mono灝咥SP.NET緙栧啓鐨刉indow鏈嶅姟縐繪嶅埌Linux涓嬭繍琛
浣跨敤鐨勮蔣浠訛細mono2.0, Linux Red hat
姝ラわ細
1銆佸湪Window涓嬬紪鍐欎竴涓猂emoting鏈嶅姟絝浣滀負Window鏈嶅姟銆傚寘鎷
銆銆RemoteServer.exe錛堟湇鍔¤繍琛屾枃浠訛級
RemoteServer.exe.config錛堥厤緗鏂囦歡錛
灝嗚繖涓や釜鏂囦歡鏀懼埌Linux緋葷粺鐨勪竴涓鐩褰曚笅錛屾湰渚嬫斁鍦/home/RemoteTest/RemoteServer涓
2銆 緙栧啓Linux鏈嶅姟鑴氭湰sjhServer錛屽皢鑴氭湰鏀懼湪 /etc/rc.d/init.d鐩褰曚笅
3銆 寤虹珛絎﹀彿閾炬帴銆傚緩絝嬬浉搴旇繍琛岀駭鍒鐨勮剼鏈絎﹀彿閾炬帴錛屾湰渚嬩腑鏄2銆3銆4銆5綰э紝浣跨敤鍛戒護 錛
cd /etc/rc.d/rc2.d (鐩稿簲鍦板緩絝嬬3綰х殑閾炬帴錛宑d鍒皉c3.d鐩褰曚笅)
ln 鈥搒 /etc/rc.d/init.d/sjhServer S97sjhServer
4銆 鍚鍔ㄦ湇鍔°備嬌鐢ㄥ懡浠わ細
service sjhService start
5銆 鏈渚嬩腑鏈変竴涓瀹㈡埛絝紼嬪簭RemoteClient.exe鐢ㄥ仛渚﹀惉銆傝繍琛孯emoteClient.exe錛岃繑鍥炶繍琛岀粨鏋滆存槑鏈嶅姟宸茬粡鍦ㄨ繍琛岋紝濡傛灉瀹㈡埛絝鍑虹幇鐩鏍囨満鍣ㄧН鏋佹嫆緇濊存槑鏈嶅姟娌℃湁鍚鍔
6銆佸仠姝㈡湇鍔★紝浣跨敤鍛戒護錛
service sjhService stop
鍒版ASP.NET鐨勬湇鍔$Щ妞嶅埌Linux灝辯畻瀹屾垚錛屽拰鍏跺畠Linux鐨勭郴緇熸湇鍔′竴鏍鳳紝鎿嶄綔鏂規硶閮戒竴鏍楓
瀛樺湪鐨勫嚑涓鐤戠偣錛
涓銆佺3鐐瑰緩絝嬬﹀彿閾炬帴鏃訛紝鍙寤虹珛浜哠鐨勯摼鎺ワ紝娌℃湁寤虹珛K鐨勯摼鎺ャ傝繕鏈夊惎鍔ㄥ拰鍋滄㈡湇鍔$殑欏哄簭鐨勫畾涔夋湁浠涔堣勫垯錛屾槸鍚﹀瑰叾瀹冩湇鍔℃湁欏哄簭涓婄殑渚濊禆銆
浜屻佹湇鍔$殑鏆傚仠涓嶈搗浣滅敤錛孯emoting榪欎釜鏈嶅姟鏄鍚︽病鏈夎繖涓姒傚康銆傚叾瀹冪被鍨嬫湇鍔℃湁寰呮祴璇曘
鍙﹀栦竴縐嶆柟寮忥細
濡備綍鍦↙inux閮ㄧ講mono錛屽苟鎴愬姛鐨勮繍琛.net紼嬪簭錛岃繕璇峰ぇ瀹跺氬氭煡璇㈠惂錛屾垜鍦ㄨ繖鏂歸潰涔熷彧鏄鎼寤烘垚鍔熶簡錛岄亣鍒扮殑闂棰樹笉瓚沖熷氾紝灝變笉璇瀵煎ぇ瀹朵簡銆
鐢╩ono鏉ュ湪Linux榪愯屼竴涓.net紼嬪簭榪樻槸寰堝規槗鐨勶紝浣嗗備綍榪愯屼竴涓鍚庡彴鏈嶅姟紼嬪簭鍛錛屼粖澶╀篃鏄璐逛簡涔濈墰浜岃檸涔嬪姏錛屾渶鍚庡熼壌涓涓媠tackoverflow涓鐨勪竴涓鍥炵瓟鏉ヨ癄閲婅繖涓闅鵑樺惂銆
Under Linux, deamons are simple background processes. No special control methods (e.g start() , stop() ) are used as in Windows. Build your service as a simple (console) application, and run it in the background. Use a tool like daemonizeto run a program as a Unix daemon, and remember to specify mono as the program to be activated.
As noted by others, mono-service is a host to run services built with the ServiceProcess assembly. Services built for Windows can use this method to run unmodified under Linux. You can control the service by sending signals to the process (see man page).
鎴戣嫳鏂囦笉鏄澶濂斤紝鍙鑳藉ぇ姒傜悊瑙e叾涓鐨勬剰鎬濄傞噷杈圭殑婊嬪懗澶у跺彲浠ヨ嚜宸辯粏緇嗗搧鍛熾
澶ц嚧鎰忔濆氨鏄璇達紝絎涓縐嶆柟寮忥細鍦↙inux涓嬪彲浠ユ妸windows鏈嶅姟鏀歸犳垚涓涓鎺у埗鍙扮▼搴忔潵榪愯屻傜浜岀嶆柟寮忥細鐢╩ono-service鏉ヨ繍琛寃indows鐨勬湇鍔$▼搴忋傚墠鎻愭槸浣犺繖涓紼嬪簭鏄鏈.net鍐欐垚鐨勩
mono-service榪愯屾椂鍙傛暟鍙堣ュ備綍閰嶇疆鍛錛
鍛戒護鏍煎紡錛歮ono-service [options] program.exe
-d:DIRECTORYUse this option to specify the working directory for the service. The default is the current directory.
-l:LOCKFILESpecifies the file to use for locking, the default is a filename constructed in /tmp based on the name of the program that hosts the service.
-m:MESSAGEName to show in the syslog.
-n:NAMEUse this to specify the service to be launched (if the program contains more than one service). The default is to run the first defined service.
--debug錛歎se this option to prevent mono-service from redirecting stdin and stdout and prevent the program to be sent to the background. Equivalent to
--no-daemon錛歎se this option to prevent mono-service from redirecting stdin and stdout and prevent the program to be sent to the background. Equivalent to --debug.
渚嬶細mono-service -l:/root/service-lock MyService.exe
鎺у埗鏈嶅姟錛堣繖鍑犵嶆搷浣滅殑鍖哄埆璇峰弬鑰僿indows鐨勪嬌鐢ㄦ柟寮忥紝榪欓噷鎴戝氨涓嶅仛榪囧氳В閲婁簡錛夛細
鏆傚仠: kill -USR1 'cat <lock file>'
緇х畫: kill -USR2 'cat <lock file>'
鍋滄: kill 'cat <lock file>'
娉ㄦ剰錛歎se mono-service to run services that use the 1.0 assemblies and use mono-service2 to run services that use the 2.0 assemblies.
mono-service鍙浠ヨ繍琛.net 1.0鐨勭▼搴忛泦錛宮ono-service2鍙浠ヨ繍琛.net 2.0鐨勭▼搴忛泦銆