當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript os.uptime函數代碼示例

本文整理匯總了TypeScript中os.uptime函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript uptime函數的具體用法?TypeScript uptime怎麽用?TypeScript uptime使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了uptime函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: Date

 ,(msg: rcf.IMessage): void => {
     console.log(new Date().toISOString() + ': msg-rcvd: ' + JSON.stringify(msg));
     let gMsg: GridMessage = msg.body;
     if (gMsg.type === 'launch-task') {
         let task: ITask = gMsg.content;
         let TrackingId = tasksTracker.beginTracking(task);
         let taskExec = getTaskExec(nodeId, gridDB);
         taskExec.on("error", (err: any) => {
             console.error(new Date().toISOString() + ": !!! Error running task " + JSON.stringify(task) + ": " + JSON.stringify(err) + " :-(");
             // TODO: sent error message to the server
         }).on("exec-params", (taskExecParams: ITaskExecParams) => {
             tasksTracker.updateTracking(TrackingId, {cmd: taskExecParams.cmd, envJSON: taskExecParams.envJSON});
             console.log(new Date().toISOString() + ": running task " + JSON.stringify(task) + " with exec-params=\n" + JSON.stringify(taskExecParams, null, 2));
         }).on("started", (pid: number) => {
             tasksTracker.updateTracking(TrackingId, {pid});
             console.log(new Date().toISOString() + ": task " + JSON.stringify(task) + " started with pid=" + pid);
         }).on("finished", (retCode: number) => {
             console.log(new Date().toISOString() + ": task " + JSON.stringify(task) + " finished with retCode=" + retCode);
         }).run(task)
         .then(() => {
             tasksTracker.endTracking(TrackingId);
             notifyDispatcherTaskComplete(task)
             .then(() => {
                 console.log(new Date().toISOString() + ': <task-complete> notification for task ' + JSON.stringify(task) + ' successfully sent to the dispatcher :-)');
             }).catch((err: any) => {
                 console.error(new Date().toISOString() + ': !!! Error sending <task-complete> notification for task '+ JSON.stringify(task) + ' to the dispatcher :-(');
             });
         });
     } else if (gMsg.type === 'kill-processes-tree') {
         let pids: number[] = gMsg.content;
         killProcessesTree(pids);
     } else if (gMsg.type === 'node-query-status') {
         let request: NodeQueryStatusRequest = gMsg.content;
         let response: NodeQueryStatusResponse = {
             QueryId: request.QueryId
             ,Status: {
                 FreeMem: os.freemem()
                 ,TotalMem: os.totalmem()
                 ,UptimeSec: os.uptime()
                 ,RunningTasks: tasksTracker.toJSON()                     
             }
         };
         sendNodeQueryStatusResponse(response)
         .then(() => {
         }).catch((err: any) => {
             console.error(new Date().toISOString() + ': !!! Error sending back <node-query-status> message: ' + JSON.stringify(err));
         });
     }
 },{})
開發者ID:wchang28,項目名稱:node-grid-2,代碼行數:49,代碼來源:launcherApp.ts

示例2: tick

	async function tick() {
		const cpu = await cpuUsage();
		const usedmem = await usedMem();
		const totalmem = await totalMem();
		const disk = diskusage.checkSync(os.platform() == 'win32' ? 'c:' : '/');

		const stats = {
			cpu_usage: cpu,
			mem: {
				total: totalmem,
				used: usedmem
			},
			disk,
			os_uptime: os.uptime(),
			process_uptime: process.uptime()
		};
		ev.emit('serverStats', stats);
		log.push(stats);
		if (log.length > 50) log.shift();
	}
開發者ID:ha-dai,項目名稱:Misskey,代碼行數:20,代碼來源:server-stats.ts

示例3:

        result = os.tmpdir();
        result = os.homedir();
        result = os.endianness();
        result = os.hostname();
        result = os.type();
        result = os.platform();
        result = os.arch();
        result = os.release();
        result = os.EOL;
    }

    {
        let result: number;

        result = os.uptime();
        result = os.totalmem();
        result = os.freemem();
    }

    {
        let result: number[];

        result = os.loadavg();
    }

    {
        let result: os.CpuInfo[];

        result = os.cpus();
    }
開發者ID:Crevil,項目名稱:DefinitelyTyped,代碼行數:30,代碼來源:node-tests.ts


注:本文中的os.uptime函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。