Mercurial > epgrec.yaz
comparison recorder.php @ 166:68f6b36e7c01
mod: デバッグバージョン
author | Sushi-k <epgrec@park.mda.or.jp> |
---|---|
date | Fri, 16 Apr 2010 17:31:18 +0900 |
parents | b3095425e613 |
children | b307e3749e80 |
comparison
equal
deleted
inserted
replaced
164:254d8a21bf36 | 166:68f6b36e7c01 |
---|---|
6 include_once( INSTALL_PATH . "/DBRecord.class.php" ); | 6 include_once( INSTALL_PATH . "/DBRecord.class.php" ); |
7 include_once( INSTALL_PATH . "/Settings.class.php" ); | 7 include_once( INSTALL_PATH . "/Settings.class.php" ); |
8 include_once( INSTALL_PATH . "/recLog.inc.php" ); | 8 include_once( INSTALL_PATH . "/recLog.inc.php" ); |
9 include_once( INSTALL_PATH . "/reclib.php" ); | 9 include_once( INSTALL_PATH . "/reclib.php" ); |
10 | 10 |
11 define("DEBUG", true ); | |
12 | |
11 // 緇剛 | 13 // 緇剛 |
12 | 14 |
13 if( ! defined( RECORDER_CMD ) ) { | 15 if( ! defined( RECORDER_CMD ) ) { |
14 define( "RECORDER_CMD", INSTALL_PATH . "/recorder.php" ); | 16 define( "RECORDER_CMD", INSTALL_PATH . "/recorder.php" ); |
15 } | 17 } |
17 $settings = Settings::factory(); | 19 $settings = Settings::factory(); |
18 $reserve_id = $argv[1]; | 20 $reserve_id = $argv[1]; |
19 $msgh_r = null; // 篆∞<祉若吾潟 | 21 $msgh_r = null; // 篆∞<祉若吾潟 |
20 $msgh_w = null; // 篆∞<祉若吾潟 | 22 $msgh_w = null; // 篆∞<祉若吾潟 |
21 | 23 |
24 $logfile = INSTALL_PATH."/settings/recorder_".$reserve_id.".log"; | |
22 | 25 |
23 // 潟潟違<祉若後篆 | 26 // 潟潟違<祉若後篆 |
24 | 27 |
25 function epgrec_get_message() { | 28 function epgrec_get_message() { |
26 global $msgh_r, $reserve_id; | 29 global $msgh_r, $reserve_id; |
66 0 => array( 'file','/dev/null','r' ), | 69 0 => array( 'file','/dev/null','r' ), |
67 1 => array( 'pipe','w' ), | 70 1 => array( 'pipe','w' ), |
68 2 => array( 'file','/dev/null','w' ), | 71 2 => array( 'file','/dev/null','w' ), |
69 ); | 72 ); |
70 | 73 |
71 $ps = proc_open( "/bin/ps -o pid,ppid -ax" , $d, $pipes ); | 74 $ps = proc_open( "/bin/ps -o pid,ppid ax" , $d, $pipes ); |
72 do { | 75 do { |
73 $st = proc_get_status( $ps ); | 76 $st = proc_get_status( $ps ); |
74 }while( $st['running'] ); | 77 }while( $st['running'] ); |
75 | 78 |
76 // 罔羣阪茯 | 79 // 罔羣阪茯 |
90 | 93 |
91 // 絎祉鴻潟絖祉鴻腟篋 | 94 // 絎祉鴻潟絖祉鴻腟篋 |
92 | 95 |
93 function epgrec_termproc( $p ) | 96 function epgrec_termproc( $p ) |
94 { | 97 { |
98 if( DEBUG ) { | |
99 global $logfile; | |
100 system( "ps ax >>".$logfile ); | |
101 system( "echo ------- >>".$logfile ); | |
102 } | |
103 | |
95 $cpids = epgrec_childproc( $p ); | 104 $cpids = epgrec_childproc( $p ); |
105 | |
106 if( DEBUG ) { | |
107 global $logfile; | |
108 | |
109 foreach( $cpids as $cpid ) { | |
110 system( "echo ".$cpid." >>".$logfile ); | |
111 } | |
112 system( "echo ------- >>".$logfile ); | |
113 } | |
96 | 114 |
97 @proc_terminate( $p ); | 115 @proc_terminate( $p ); |
98 sleep(1); | 116 sleep(1); |
99 @proc_terminate( $p ); // 2綺 | 117 @proc_terminate( $p ); // 2綺 |
100 | 118 |
101 foreach( $cpids as $cpid ) { | 119 foreach( $cpids as $cpid ) { |
102 @posix_kill( $cpid, SIGTERM ); // sigterm | 120 $ret = posix_kill( $cpid, SIGTERM ); // sigterm |
103 usleep(100); | 121 usleep(100*1000); |
104 @posix_kill( $cpid, SIGKILL ); // sigkill | 122 if( ! $ret ) posix_kill( $cpid, SIGKILL ); // sigkill |
105 } | 123 } |
106 | 124 |
125 if( DEBUG ) { | |
126 global $logfile; | |
127 system( "ps ax >>".$logfile ); | |
128 system( "echo ------- >>".$logfile ); | |
129 } | |
130 | |
131 foreach( $cpids as $cpid ) { | |
132 $ret = posix_kill( $cpid, SIGTERM ); // sigterm | |
133 if( $ret ) return false; // 祉鴻絖с | |
134 } | |
107 return true; // 篆荐若с | 135 return true; // 篆荐若с |
108 } | 136 } |
109 | 137 |
110 ////// 膩 | 138 ////// 膩 |
111 | |
112 | 139 |
113 // <祉若吾潟緇 | 140 // <祉若吾潟緇 |
114 $ipc_key = ftok( RECORDER_CMD, "R" ); | 141 $ipc_key = ftok( RECORDER_CMD, "R" ); |
115 $msgh_r = msg_get_queue( $ipc_key ); | 142 $msgh_r = msg_get_queue( $ipc_key ); |
116 | 143 |