Add cleanup script to fix any problems arising from restarting the server mid-stream.
This may cause further problems if the user manages to reconnect before the cleanup script has finished, but the server *shouldn't* start listening until after the script is done. Increment version I guess, I don't really know how versioning works.merge-requests/1/head
parent
8cc8083361
commit
61bf54de95
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "satyr",
|
"name": "satyr",
|
||||||
"version": "0.2.0",
|
"version": "0.3.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -2370,6 +2370,14 @@
|
||||||
"readable-stream": "^2.0.2"
|
"readable-stream": "^2.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"recursive-readdir": {
|
||||||
|
"version": "2.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.2.tgz",
|
||||||
|
"integrity": "sha512-nRCcW9Sj7NuZwa2XvH9co8NPeXUBhZP7CRKJtU+cS6PW9FpCIFoI5ib0NT1ZrbNuPoRy0ylyCaUL8Gih4LSyFg==",
|
||||||
|
"requires": {
|
||||||
|
"minimatch": "3.0.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"regex-not": {
|
"regex-not": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "satyr",
|
"name": "satyr",
|
||||||
"version": "0.3.0",
|
"version": "0.3.1",
|
||||||
"description": "A livestreaming server.",
|
"description": "A livestreaming server.",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"author": "knotteye",
|
"author": "knotteye",
|
||||||
|
@ -24,6 +24,7 @@
|
||||||
"mysql": "^2.17.1",
|
"mysql": "^2.17.1",
|
||||||
"node-media-server": ">=2.1.3 <3.0.0",
|
"node-media-server": ">=2.1.3 <3.0.0",
|
||||||
"nunjucks": "^3.2.0",
|
"nunjucks": "^3.2.0",
|
||||||
|
"recursive-readdir": "^2.2.2",
|
||||||
"socket.io": "^2.3.0",
|
"socket.io": "^2.3.0",
|
||||||
"toml": "^3.0.0"
|
"toml": "^3.0.0"
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
import * as db from "./database";
|
||||||
|
import * as read from "recursive-readdir";
|
||||||
|
import * as fs from "fs";
|
||||||
|
|
||||||
|
async function init(siteDir: string) {
|
||||||
|
//If satyr is restarted in the middle of a stream
|
||||||
|
//it causes problems
|
||||||
|
//Live flags in the database stay live
|
||||||
|
await db.query('update user_meta set live=false');
|
||||||
|
//and stray m3u8 files will play the last
|
||||||
|
//few seconds of a stream back
|
||||||
|
try {
|
||||||
|
var files = await read(siteDir+'/live', ['!*.m3u8']);
|
||||||
|
}
|
||||||
|
catch (error) {}
|
||||||
|
if(files === undefined || files.length == 0) return;
|
||||||
|
for(let i=0;i<files.length;i++){
|
||||||
|
fs.unlinkSync(files[i]);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
export { init };
|
|
@ -2,9 +2,10 @@ import * as mediaserver from "./server";
|
||||||
import * as db from "./database";
|
import * as db from "./database";
|
||||||
import * as api from "./api";
|
import * as api from "./api";
|
||||||
import * as http from "./http";
|
import * as http from "./http";
|
||||||
|
import * as cleanup from "./cleanup"
|
||||||
import * as config from "config";
|
import * as config from "config";
|
||||||
|
|
||||||
function run(): void{
|
async function run() {
|
||||||
const dbcfg: object = config.database;
|
const dbcfg: object = config.database;
|
||||||
const bcryptcfg: object = config.bcrypt;
|
const bcryptcfg: object = config.bcrypt;
|
||||||
const satyr: object = {
|
const satyr: object = {
|
||||||
|
@ -52,9 +53,10 @@ function run(): void{
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
db.init(dbcfg, bcryptcfg);
|
||||||
|
await cleanup.init(config.server.http.directory);
|
||||||
api.init(satyr);
|
api.init(satyr);
|
||||||
http.init(satyr, config.server.http.port);
|
http.init(satyr, config.server.http.port);
|
||||||
db.init(dbcfg, bcryptcfg);
|
|
||||||
mediaserver.init(nms, satyr);
|
mediaserver.init(nms, satyr);
|
||||||
}
|
}
|
||||||
run();
|
run();
|
||||||
|
|
Reference in New Issue