Rev 464 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/usr/bin/php<?php/*安裝方式:將該檔案移動到 /usr/bin/ 底下描述:確認 mariabdb 有在運作*/#使用命名空間qbpwcfnamespace qbpwcf;#匯入套件include("/usr/lib/qbpwcf/allInOne.php");#無窮迴圈while(true){#查詢服務啟動沒#涵式說明:#執行 systemd 程序來管理服務.#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息.#$result["function"],當前執行的函數名稱.#$result["argu"],所使用的參數.#$result["content"],執行的結果.#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行.#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動.#必填參數:#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑$conf["fileArgu"]=__FILE__;#$conf["name"],字串,服務名稱.$conf["name"]="mariadb";#可省略參數:#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".$conf["operation"]="status";#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者#$conf["username"]="";#$conf["password"],字串,使用者的密碼,預設不使用.#$conf["password"]="";$systemd=cmd::systemd($conf);unset($conf);#若運行出錯if($systemd["status"]==="false"){#debugvar_dump($systemd);#停止執行exit;}#if end#如果服務沒啟動if($systemd["content"]["srerviceInfo"]["on"]==="false"){#啟動服務#涵式說明:#執行 systemd 程序來管理服務.#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息.#$result["function"],當前執行的函數名稱.#$result["argu"],所使用的參數.#$result["content"],執行的結果.#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行.#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動.#必填參數:#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑$conf["fileArgu"]=__FILE__;#$conf["name"],字串,服務名稱.$conf["name"]="mariadb";#可省略參數:#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".$conf["operation"]="start";#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者#$conf["username"]="";#$conf["password"],字串,使用者的密碼,預設不使用.#$conf["password"]="";$systemd=cmd::systemd($conf);unset($conf);#若運行出錯if($systemd["status"]==="false"){#debugvar_dump($systemd);#停止執行exit;}#if end}#if end#過30秒再檢查一次sleep(30);#下一輪continue;}#while end?>