Mercurial > epgrec.yaz
annotate storeProgram.php @ 125:ef3df87f3c7d
mod: チャンネルスキップの大まかな実装終了
author | Sushi-k <epgrec@park.mda.or.jp> |
---|---|
date | Wed, 17 Mar 2010 18:12:01 +0900 |
parents | 3bed74eca373 |
children | b3ba2658a228 |
rev | line source |
---|---|
83
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
1 #!/usr/bin/php |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
2 <?php |
111
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
95
diff
changeset
|
3 $script_path = dirname( __FILE__ ); |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
95
diff
changeset
|
4 chdir( $script_path ); |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
95
diff
changeset
|
5 include_once( $script_path . '/config.php'); |
83
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
6 |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
7 $type = $argv[1]; // BS CS GR |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
8 $file = $argv[2]; // XML<ゃ |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
9 |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
10 // SIGTERM激違 |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
11 function handler( $signo = 0 ) { |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
12 global $file; |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
13 if( file_exists( $file ) ) { |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
14 @unlink( $file ); |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
15 } |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
16 exit(); |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
17 } |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
18 |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
19 // 若≪喝 |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
20 function daemon() { |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
21 if( pcntl_fork() != 0 ) |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
22 exit(); |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
23 posix_setsid(); |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
24 if( pcntl_fork() != 0 ) |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
25 exit; |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
26 pcntl_signal(SIGTERM, "handler"); |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
27 } |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
28 |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
29 // 若≪喝 |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
30 daemon(); |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
31 // ゃd |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
32 pcntl_setpriority(20); |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
33 |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
34 include_once( INSTALL_PATH . '/DBRecord.class.php' ); |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
35 include_once( INSTALL_PATH . '/Reservation.class.php' ); |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
36 include_once( INSTALL_PATH . '/Keyword.class.php' ); |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
37 include_once( INSTALL_PATH . '/Settings.class.php' ); |
111
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
95
diff
changeset
|
38 include_once( INSTALL_PATH . '/storeProgram.inc.php' ); |
83
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
39 |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
40 $settings = Settings::factory(); |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
41 |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
42 if( file_exists( $file ) ) { |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
43 storeProgram( $type, $file ); |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
44 @unlink( $file ); |
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
45 } |
111
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
95
diff
changeset
|
46 garbageClean(); // 筝荀違 |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
95
diff
changeset
|
47 doKeywordReservation(); // 若若篋膣 |
83
f873e3251487
new: EPG取得の並列化テストを追加
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
diff
changeset
|
48 ?> |