Subversion Repositories php-qbpwcf

Rev

Rev 223 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 liveuser 1
<?php
2
 
3
/*
4
 
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
239 liveuser 6
    Copyright (C) 2014~2026 MIN ZHI, CHEN
1 liveuser 7
 
8
    This file is part of QBPWCF.
9
 
10
    QBPWCF is free software: you can redistribute it and/or modify
11
    it under the terms of the GNU General Public License as published by
12
    the Free Software Foundation, either version 3 of the License, or
13
    (at your option) any later version.
14
 
15
    QBPWCF is distributed in the hope that it will be useful,
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    GNU General Public License for more details.
19
 
20
    You should have received a copy of the GNU General Public License
21
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
22
 
23
*/
24
 
25
#使用命名空間qbpwcf
26
namespace qbpwcf;
27
 
28
#assets dir
29
$assetsDir="assets_of_threads::proc_20250221";
30
 
31
#要運行的php程式
32
$cmd=<<<'PHP'
33
 
34
/*
35
 
36
        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
239 liveuser 37
    Copyright (C) 2014~2026 MIN ZHI, CHEN
1 liveuser 38
 
39
    This file is part of QBPWCF.
40
 
41
    QBPWCF is free software: you can redistribute it and/or modify
42
    it under the terms of the GNU General Public License as published by
43
    the Free Software Foundation, either version 3 of the License, or
44
    (at your option) any later version.
45
 
46
    QBPWCF is distributed in the hope that it will be useful,
47
    but WITHOUT ANY WARRANTY; without even the implied warranty of
48
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
49
    GNU General Public License for more details.
50
 
51
    You should have received a copy of the GNU General Public License
52
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
53
 
54
*/
55
 
56
#使用命名空間qbpwcf
57
namespace qbpwcf;
58
 
59
#匯入套件
60
require_once("qbpwcf/allInOne.php");
61
 
62
#建議的log位置
63
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
64
 
65
#設置要等待1天
66
$second2wait=86400;
67
 
68
#提示開始時間
69
echo "start in ".gmdate("Y-M-D H:i:s").PHP_EOL;
70
 
71
#當還有時間要等待時
72
while($second2wait>0){
73
 
74
	#等待1秒鐘
75
	sleep(1);
223 liveuser 76
 
1 liveuser 77
	#設置等待時間減少1秒鐘
78
	$second2wait=$second2wait-1;
79
 
80
	#提示剩下多少等待時間
81
	echo "There is still ".$second2wait." left.".PHP_EOL;
82
 
83
	}#while end
84
 
85
#提示結束時間
86
echo "end in ".gmdate("Y-M-D H:i:s").PHP_EOL;
87
 
88
PHP;
89
 
90
#透過 php -a 來運行 php程式
91
$cmd="php -r ".escapeshellarg($cmd);
92
 
93
#函式說明:
94
#透過proc來多執行序運作.
95
#回傳結果:
96
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
97
#$reuslt["error"],執行不正常結束的錯訊息陣列.
98
#$result["function"],當前執行的函式名稱.
99
#$result["content"],陣列,每個元素為其指令執行的結果訊息陣列,key為"status"代表執行是否正常的識別;key為"statusCode"代表程式結束後回傳給對應executeBy程式的數值;key為"output"代表標準輸出,若為resource,則代表為pipe;key為"error"代表非標準輸出,若為resource,則代表為pipe;key為"input"代表成功輸入的指令;key為"process"代表該程序經proc_open後的process source.
100
#必填參數:
101
#$conf["cmds"],字串陣列,每個元素代表要執行的指令與參數.
102
$conf["cmds"]=array($cmd);
103
#可省略參數:
104
#$conf["wait"],字串,是否需要等待所有程序結束,預設為"true"要等待;反之為"false"不要等待.
105
#$conf["wait"]="false";
106
#$conf["workingDir"],字串陣列,個別程式執行時的家目錄,預設不指定.
107
#$conf["workingDir"]=array("path");
108
#$conf["envs"],2維字串陣列,每個元素代表個別程式執行時的指定環境變數,key變數名稱;value為變數內容.預設為array("QBPWCF" => "Quick Build PHP Website Componment base on Fedora Linux");
109
#$conf["envs"]=array(array("key"=>"value"));
110
#$conf["executeBy"],字串陣列,每個元素代表個別指令要用什麼程式執行,預設為"bash".
111
#$conf["executeBy"]=array("php");
112
#參考資料:
113
#https://www.php.net/manual/en/function.proc-open.php
114
#備註:
115
#無.
116
$proc=threads::proc($conf);
117
unset($conf);
118
 
119
#debug
223 liveuser 120
var_dump($proc);