Mercurial > epgrec.yaz
comparison storeProgram.php @ 159:66eabfc1b118
revoke all whitespace modifications
| author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
|---|---|
| date | Wed, 31 Mar 2010 06:42:51 +0900 |
| parents | b3ba2658a228 |
| children |
comparison
equal
deleted
inserted
replaced
| 158:be39a7efcc87 | 159:66eabfc1b118 |
|---|---|
| 4 chdir( $script_path ); | 4 chdir( $script_path ); |
| 5 include_once( $script_path . '/config.php'); | 5 include_once( $script_path . '/config.php'); |
| 6 | 6 |
| 7 $type = $argv[1]; // BS CS GR | 7 $type = $argv[1]; // BS CS GR |
| 8 $file = $argv[2]; // XMLファイル | 8 $file = $argv[2]; // XMLファイル |
| 9 | 9 |
| 10 // SIGTERMシグナル | 10 // SIGTERMシグナル |
| 11 function handler( $signo = 0 ) { | 11 function handler( $signo = 0 ) { |
| 12 global $file; | 12 global $file; |
| 13 if( file_exists( $file ) ) { | 13 if( file_exists( $file ) ) { |
| 14 @unlink( $file ); | 14 @unlink( $file ); |
| 15 } | 15 } |
| 16 exit(); | 16 exit(); |
| 17 } | 17 } |
| 18 | 18 |
| 19 // デーモン化 | 19 // デーモン化 |
| 20 function daemon() { | 20 function daemon() { |
| 21 if( pcntl_fork() != 0 ) | 21 if( pcntl_fork() != 0 ) |
| 22 exit(); | 22 exit(); |
| 23 posix_setsid(); | 23 posix_setsid(); |
| 24 if( pcntl_fork() != 0 ) | 24 if( pcntl_fork() != 0 ) |
| 25 exit; | 25 exit; |
| 26 pcntl_signal(SIGTERM, "handler"); | 26 pcntl_signal(SIGTERM, "handler"); |
| 27 } | 27 } |
| 28 | 28 |
| 29 // デーモン化 | 29 // デーモン化 |
| 30 daemon(); | 30 daemon(); |
| 31 // プライオリティ低に | 31 // プライオリティ低に |
| 32 pcntl_setpriority(20); | 32 pcntl_setpriority(20); |
| 33 | 33 |
| 34 include_once( INSTALL_PATH . '/DBRecord.class.php' ); | 34 include_once( INSTALL_PATH . '/DBRecord.class.php' ); |
| 35 include_once( INSTALL_PATH . '/Reservation.class.php' ); | 35 include_once( INSTALL_PATH . '/Reservation.class.php' ); |
| 36 include_once( INSTALL_PATH . '/Keyword.class.php' ); | 36 include_once( INSTALL_PATH . '/Keyword.class.php' ); |
| 37 include_once( INSTALL_PATH . '/Settings.class.php' ); | 37 include_once( INSTALL_PATH . '/Settings.class.php' ); |
| 38 include_once( INSTALL_PATH . '/storeProgram.inc.php' ); | 38 include_once( INSTALL_PATH . '/storeProgram.inc.php' ); |
| 39 | 39 |
| 40 $settings = Settings::factory(); | 40 $settings = Settings::factory(); |
| 41 | 41 |
| 42 if( file_exists( $file ) ) { | 42 if( file_exists( $file ) ) { |
| 43 storeProgram( $type, $file ); | 43 storeProgram( $type, $file ); |
| 44 @unlink( $file ); | 44 @unlink( $file ); |
| 45 } | 45 } |
| 46 garbageClean(); // 不要プログラム削除 | 46 garbageClean(); // 不要プログラム削除 |
