Subversion Repositories qbpwcf-lib(archive)

Rev

Rev 620 | Rev 906 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 liveuser 1
#!/usr/bin/php
2
<?php
3
 
4
/*
464 liveuser 5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
620 liveuser 6
    Copyright (C) 2015~2024 Min-Jhin,Chen
464 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
/*
1 liveuser 26
安裝方式:
27
將該檔案移動到 /usr/bin/ 底下
28
 
29
描述:
30
確認 mariabdb 有在運作
31
*/
32
 
33
#使用命名空間qbpwcf
34
namespace qbpwcf;
35
 
466 liveuser 36
#以該檔案的實際位置的 lib path 為 include path 首位
37
exec("cd ".pathinfo(__FILE__)["dirname"]."/../../;pwd;",$output,$status);
38
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
39
 
464 liveuser 40
#匯入外部套件
466 liveuser 41
include("allInOne.php");
1 liveuser 42
 
43
#無窮迴圈
44
while(true){
45
 
46
	#查詢服務啟動沒
47
	#涵式說明:
48
	#執行 systemd 程序來管理服務.
49
	#回傳結果:
50
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
51
	#$result["error"],錯誤訊息.
52
	#$result["function"],當前執行的函數名稱.
53
	#$result["argu"],所使用的參數.
54
	#$result["content"],執行的結果.
55
	#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
56
	#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
57
	#必填參數:
58
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
59
	$conf["fileArgu"]=__FILE__;
60
	#$conf["name"],字串,服務名稱.
61
	$conf["name"]="mariadb";
62
	#可省略參數:
63
	#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
64
	$conf["operation"]="status";
65
	#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
66
	#$conf["username"]="";
67
	#$conf["password"],字串,使用者的密碼,預設不使用.
68
	#$conf["password"]="";
69
	$systemd=cmd::systemd($conf);
70
	unset($conf);
71
 
72
	#若運行出錯
73
	if($systemd["status"]==="false"){
74
 
75
		#debug
76
		var_dump($systemd);
77
 
78
		#停止執行
79
		exit;
80
 
81
		}#if end
82
 
83
	#如果服務沒啟動
84
	if($systemd["content"]["srerviceInfo"]["on"]==="false"){
85
 
86
		#啟動服務
87
		#涵式說明:
88
		#執行 systemd 程序來管理服務.
89
		#回傳結果:
90
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
91
		#$result["error"],錯誤訊息.
92
		#$result["function"],當前執行的函數名稱.
93
		#$result["argu"],所使用的參數.
94
		#$result["content"],執行的結果.
95
		#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
96
		#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
97
		#必填參數:
98
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
99
		$conf["fileArgu"]=__FILE__;
100
		#$conf["name"],字串,服務名稱.
101
		$conf["name"]="mariadb";
102
		#可省略參數:
103
		#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
104
		$conf["operation"]="start";
105
		#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
106
		#$conf["username"]="";
107
		#$conf["password"],字串,使用者的密碼,預設不使用.
108
		#$conf["password"]="";
109
		$systemd=cmd::systemd($conf);
110
		unset($conf);
111
 
112
		#若運行出錯
113
		if($systemd["status"]==="false"){
114
 
115
			#debug
116
			var_dump($systemd);
117
 
118
			#停止執行
119
			exit;
120
 
121
			}#if end
122
 
123
		}#if end
124
 
125
	#過30秒再檢查一次
126
	sleep(30);
127
 
128
	#下一輪
129
	continue;
130
 
131
	}#while end
132
 
133
?>