diff --git a/app.js b/app.js index 1308732..4281bd2 100644 --- a/app.js +++ b/app.js @@ -45,7 +45,7 @@ disk ); daemon( - `ffmpeg -i rtmp://localhost:1935/live/bushitsuchan -hls_flags delete_segments -codec:v copy -g 40 -f hls ${mountPath}/output.m3u8`, + `ffmpeg -i rtmp://localhost:1935/live/bushitsuchan -hls_flags delete_segments -g 40 -f hls ${mountPath}/output.m3u8`, ); let ngrokUrl; diff --git a/utils.js b/utils.js index 58ad52b..c8961a8 100644 --- a/utils.js +++ b/utils.js @@ -1,18 +1,23 @@ const childProcess = require('child_process'); const util = require('util'); +const fs = require('fs'); const exec = util.promisify(childProcess.exec); const wait = ms => new Promise(reolve => setTimeout(() => reolve(), ms)); module.exports.daemon = async (command, ms = 1000 * 10, maxCount = 100) => { + const logger = new console.Console( + fs.createWriteStream('out.log'), + fs.createWriteStream('err.log'), + ); console.log(`start daemon ${command.slice(0, 40)}...`); for (let i = 0; i < maxCount; i += 1) { try { // eslint-disable-next-line no-await-in-loop await exec(command); } catch (e) { - console.error(e); + logger.error(e); // eslint-disable-next-line no-await-in-loop await wait(ms); }