1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

        GTask任務(wù)管理系統(tǒng)

        聯(lián)合創(chuàng)作 · 2023-09-29 14:42

        GTask 支持遠(yuǎn)程管理任務(wù),執(zhí)行任務(wù)腳本(目前僅支持 lua),開發(fā)者可以創(chuàng)建任務(wù)實(shí)例并為實(shí)例添加處理器,在處理器中配置執(zhí)行腳本就可以輕松地管理任務(wù)。

        編譯與使用

        Linux

        ./build/linux.sh

        MaxOS

        ./build/macos.sh

        編譯成功后在release目錄下會生成兩個文件,gtaskclient,分別是服務(wù)端程序和客戶端程序。

        服務(wù)端運(yùn)行

        config/config.json中保存著服務(wù)端監(jiān)聽的端口號和登陸的密鑰,在客戶端連接服務(wù)器的時(shí)候?qū)玫皆撁荑€。啟動服務(wù)端時(shí)需要指定配置參數(shù)。

        ./release/gtask -cfg ./config/config.json

        客戶端連接服務(wù)器

        ./release/client -h [host] -p 1126

        這時(shí)會要求輸入密鑰,該密鑰是初始化服務(wù)器時(shí)候的密鑰。

        客戶端指令說明介紹

        指令 參數(shù) 參數(shù)介紹 示例
        create job key 任務(wù)key create job test
        use key 該key必須已經(jīng)被創(chuàng)建 use test
        create processor [filePath trigger bReset bLoop bExit] (必須先use job) [腳本文件 觸發(fā)時(shí)間(秒) 能否被重置 是否循環(huán) 是否退出] create processor ./example/lua/test_json.lua 3 0 1 0
        run   (必須先use job)啟動任務(wù) run
        delete   (必須先use job)停止并刪除任務(wù) delete

        客戶端演示

        test.gif

        客戶端測試

        使用默認(rèn)配置文件并將服務(wù)端運(yùn)行在本機(jī)(localhost)

        ./release/client -h localhost -p 1126
        secretKey:647851f2fcf6101aefa4a2c59a329a11c60300a4
        
        # 創(chuàng)建任務(wù)
        > create job test
        create job [test] success
        
        # 選擇任務(wù)
        > use test
        select job [test]
        
        # 為任務(wù)創(chuàng)建執(zhí)行器,解析json并打印相關(guān)數(shù)據(jù),3秒執(zhí)行一次,循環(huán)執(zhí)行
        test > create processor ./example/lua/test_json.lua 3 0 1 0
        create processor success
        
        # 運(yùn)行任務(wù)
        test > run
        run job [test] success
        
        # 為任務(wù)補(bǔ)充一條執(zhí)行器,用來發(fā)送GET請求獲取網(wǎng)站數(shù)據(jù),5秒執(zhí)行一次,循環(huán)執(zhí)行
        test > create processor ./example/lua/test_http_get.lua 5 0 1 0
        create processor success
        
        # 停止并刪除當(dāng)前任務(wù)
        test > delete
        >

        LUA執(zhí)行代碼介紹

        // 函數(shù)名必須是processor
        // key(string): 任務(wù)key
        // count(number): 時(shí)間計(jì)數(shù)
        function processor(key,count)
            data = {}
            data["hello"]="world"
            data["a"] = {}
            data["a"]["b"] = "b"
            data["a"]["c"] = {1,2,3,4,5,6}
            res = jsonMarshal(data)
            res = jsonUnMarshal(res)
            for k,v in ipairs(res["a"]["c"]) do
                print(k,v)
            end
            return true // 如果返回false,當(dāng)前執(zhí)行器將會退出
        end

        LUA支持函數(shù)

        加密

        函數(shù) 參數(shù) 返回值 描述
        md5 string string 獲取字符串的MD5值
        base64 string string 獲取字符串的base64編碼
        base64UrlSafe string string 獲取字符串url安全的base64編碼
        base64 string string 獲取字符串的base64編碼
        hmac [key:string, str:string] string 獲取hmac值
        sha1 string string 獲取字符串的SHA1值

        時(shí)間

        函數(shù) 參數(shù) 返回值 描述
        now   number 獲取當(dāng)前時(shí)間戳(毫秒)

        Json

        函數(shù) 參數(shù) 返回值 描述
        jsonMarshal table string 將table轉(zhuǎn)換成json字符串
        jsonUnMarshal string table 將json字符串轉(zhuǎn)轉(zhuǎn)換成table

        Http

        函數(shù) 參數(shù) 返回值 描述
        httpGet [url:string header:table] [res:string ok:bool] 發(fā)送GET請求
        httpPost [url:string header:table body:string] [res:string ok:bool] 發(fā)送POST請求
        瀏覽 27
        點(diǎn)贊
        評論
        收藏
        分享

        手機(jī)掃一掃分享

        編輯 分享
        舉報(bào)
        評論
        圖片
        表情
        推薦
        點(diǎn)贊
        評論
        收藏
        分享

        手機(jī)掃一掃分享

        編輯 分享
        舉報(bào)
        1. <strong id="7actg"></strong>
        2. <table id="7actg"></table>

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            99久久99久久免费精品不卡 | 日韩精品在线播放 | 影音先锋蜜桃 | 少妇高潮又黄又爽免费网站 | 精品无码视频在线 | 男女操逼视频网 | 人人搞人人操 | 成人做爱视频网址 | 少妇裸体淫交视频 | 久久足交 |