本文整理汇总了TypeScript中tail.Tail类的典型用法代码示例。如果您正苦于以下问题:TypeScript Tail类的具体用法?TypeScript Tail怎么用?TypeScript Tail使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tail类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: latestVersion
latestVersion("mirakurun").then(latest => {
if (!req.query.force && current === latest) {
api.responseError(res, 409, "Update Nothing");
return;
}
let command;
const args = [
"install",
"mirakurun@latest",
"-g",
"--production"
];
if (process.platform === "win32") {
command = "npm.cmd";
} else {
command = "npm";
args.push("--unsafe");
}
res.setHeader("Content-Type", "text/plain; charset=utf-8");
res.status(202);
res.write("Updating...\n");
const path = join(tmpdir(), "Mirakurun_Updating.log");
if (existsSync(path) === true) {
unlinkSync(path);
}
const out = openSync(path, "a");
const err = openSync(path, "a");
res.write(`> ${command} ${args.join(" ")}\n\n`);
const npm = spawn(command, args, {
detached: true,
stdio: ["ignore", out, err]
});
npm.unref();
const tail = new Tail(path);
tail.on("line", data => res.write(data + "\n"));
req.once("close", () => {
tail.removeAllListener("line");
tail.unwatch();
});
});
开发者ID:tosono,项目名称:Mirakurun,代码行数:49,代码来源:update.ts
示例2: async
export const put: Operation = async (req, res) => {
if (!req.query.force && !process.env.pm_uptime && !process.env.USING_WINSER) {
api.responseError(res, 500);
return;
}
const latest = await latestVersion("mirakurun");
if (!req.query.force && current === latest) {
api.responseError(res, 409, "Update Nothing");
return;
}
res.setHeader("Content-Type", "text/plain; charset=utf-8");
res.status(202);
res.write("Updating...\n");
const path = join(tmpdir(), "Mirakurun_Updating.log");
if (existsSync(path) === true) {
unlinkSync(path);
}
const out = openSync(path, "a");
const err = openSync(path, "a");
res.write(`> node lib/updater\n\n`);
const npm = spawn("node", ["lib/updater"], {
detached: true,
stdio: ["ignore", out, err]
});
npm.unref();
const tail = new Tail(path);
tail.on("line", data => res.write(data + "\n"));
req.once("close", () => {
tail.removeAllListeners("line");
tail.unwatch();
});
};
开发者ID:upsilon,项目名称:Mirakurun,代码行数:42,代码来源:update.ts
示例3: watchFile
function watchFile(file:any) {
const tail = new Tail(file);
// Specific errors handling
process.on('uncaughtException', (err:any) => {
if (err.code === "ENOENT") {
console.error('EXCEPTION: ', err.message);
setTimeout(() => watchFile(file), 1000) // Wait a second
}
});
// On new line
tail.on("line", function(data:any) {
console.log(data);
});
tail.on("error", function(error:any) {
console.error('ERROR: ', error);
});
}
开发者ID:duniter,项目名称:duniter,代码行数:20,代码来源:daemon.ts
示例4: return
return () => {
let logTail = new Tail(
tailConfig.filename,
tailConfig.lineSeparator,
tailConfig.watchOptions,
tailConfig.fromStart
);
return new Observable(o => {
logTail.on('line', (line) => o.next(line));
logTail.on('err', (err) => o.error(err));
logTail.on('end', () => o.complete());
});
};
开发者ID:jonesnc,项目名称:gustav,代码行数:13,代码来源:helpers.ts
示例5: Tail
export const get: Operation = (req, res) => {
if (!process.env.LOG_STDOUT || !process.env.LOG_STDERR) {
res.writeHead(500, "Unknown Logfile Path", {
"Content-Type": "text/plain"
});
res.end("Unknown Logfile Path");
return;
}
if (!fs.existsSync(process.env.LOG_STDOUT) || !fs.existsSync(process.env.LOG_STDERR)) {
res.writeHead(500, "Logfile Unavailable", {
"Content-Type": "text/plain"
});
res.end("Logfile Unavailable");
return;
}
res.setHeader("Content-Type", "text/plain; charset=utf-8");
res.status(200);
const stdout = new Tail(process.env.LOG_STDOUT);
const stderr = new Tail(process.env.LOG_STDERR);
req.setTimeout(1000 * 60 * 60, () => { });
req.once("close", () => {
stdout.removeListener("line", _listener);
stdout.unwatch();
stderr.removeListener("line", _listener);
stderr.unwatch();
});
stdout.on("line", _listener);
stderr.on("line", _listener);
function _listener(data: string) {
res.write(data + "\n");
}
};
开发者ID:tosono,项目名称:Mirakurun,代码行数:38,代码来源:stream.ts
示例6: Observable
return new Observable(o => {
logTail.on('line', (line) => o.next(line));
logTail.on('err', (err) => o.error(err));
logTail.on('end', () => o.complete());
});
开发者ID:jonesnc,项目名称:gustav,代码行数:5,代码来源:helpers.ts
示例7: Tail
import { Tail } from 'tail';
const tail = new Tail("test.txt");
tail.on("line", data => {
console.log(data);
});
tail.on("error", error => {
console.log('ERROR: ', error);
});
tail.unwatch();
tail.watch();
// With options object
const tail2 = new Tail("test2.txt", {
separator: /[\r]{0,1}\n/,
fromBeginning: false,
fsWatchOptions: {},
follow: true,
logger: console,
useWatchFile: false,
encoding: 'utf-8'
});
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:26,代码来源:tail-tests.ts
示例8:
req.once("close", () => {
tail.removeAllListener("line");
tail.unwatch();
});
开发者ID:tosono,项目名称:Mirakurun,代码行数:4,代码来源:update.ts
示例9:
req.once("close", () => {
stdout.removeListener("line", _listener);
stdout.unwatch();
stderr.removeListener("line", _listener);
stderr.unwatch();
});
开发者ID:tosono,项目名称:Mirakurun,代码行数:6,代码来源:stream.ts
注:本文中的tail.Tail类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论