Subversion Repositories qbpwcf-lib(archive)

Rev

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

Rev Author Line No. Line
670 liveuser 1
#!/bin/php
668 liveuser 2
<?php
3
 
4
/*
5
 
6
        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
7
    Copyright (C) 2015~2024 Min-Jhin,Chen
8
 
9
    This file is part of QBPWCF.
10
 
11
    QBPWCF is free software: you can redistribute it and/or modify
12
    it under the terms of the GNU General Public License as published by
13
    the Free Software Foundation, either version 3 of the License, or
14
    (at your option) any later version.
15
 
16
    QBPWCF is distributed in the hope that it will be useful,
17
    but WITHOUT ANY WARRANTY; without even the implied warranty of
18
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
    GNU General Public License for more details.
20
 
21
    You should have received a copy of the GNU General Public License
22
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
23
 
24
*/
25
 
26
#使用命名空間qbpwcf
27
namespace qbpwcf;
28
 
29
#匯入套件
30
require_once("qbpwcf/allInOneForJson.php");
31
 
32
#建議的log位置
33
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
34
 
35
#函式說明:
36
#執行程式時,依照需要增加記憶體的上限.
37
#回傳結果:
38
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
39
#$result["error"],錯誤訊息陣列.
40
#$result["function"],當前執行的函數名稱.
41
#$result["argu"],使用的參數.
42
#$result["content"],程式執行後的結果.
43
#必填參數:
44
#$conf["cmd"],字串參數,要執行的指令.
670 liveuser 45
#$conf["cmd"]="uname";
46
#$conf["cmd"]="echo";
47
#$conf["cmd"]="ps";
668 liveuser 48
$conf["cmd"]="sleep";
49
#可省略參數:
50
#$conf["params"],陣列字串參數,每個元素代表依序哦昂使用的參數.
670 liveuser 51
#$conf["params"]=array("-a");
52
#$conf["params"]=array("Hello World");
53
#$conf["params"]=array("auxwf");
54
$conf["params"]=array("5",";","ps","auxwf","|","cat");
668 liveuser 55
#參考資料:
56
#https://www.php.net/manual/en/function.memory-get-usage.php
57
#https://www.php.net/manual/en/ini.core.php#ini.memory-limit
58
#備註:
59
#無.
60
$runWithAutoAddMemoryDaemon=sock::runWithAutoAddMemoryDaemon($conf);
61
unset($conf);
62
 
63
#如果執行失敗
64
if($runWithAutoAddMemoryDaemon["status"]==="false"){
65
 
66
	#函式說明:
67
	#撰寫log
68
	#回傳結果:
69
	#$result["status"],狀態,"true"或"false".
70
	#$result["error"],錯誤訊息陣列.
71
	#$result["function"],當前函式的名稱.
72
	#$result["argu"],使用的參數.
73
	#必填參數:
74
	#$conf["path"],字串,log檔案的路徑與名稱.
75
	$conf["path"]=$logFile;
76
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
77
	$conf["content"]=$runWithAutoAddMemoryDaemon;
78
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
79
	$conf["fileArgu"]=__FILE__;
80
	#可省略參數:
81
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
82
	#$conf["rewrite"]="false";
83
	#參考資料:
84
	#無.
85
	#備註:
86
	#無.
87
	$record=logs::record($conf);
88
	unset($conf);
89
 
90
	#結束執行
91
	exit;
92
 
93
	}#if end
94
 
95
#印出結果
96
var_dump($runWithAutoAddMemoryDaemon);
97
 
670 liveuser 98
?>