Skip to content

Commit 9ec382f

Browse files
committed
/crash, update yt-dlp on start, newer node fix
1 parent 0a771c1 commit 9ec382f

9 files changed

Lines changed: 72 additions & 20 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ It just works, but you can also check [user/ folder](/user/README.md) for server
8383
- `/unban Foo` (`/removeBan`) - Unban user `Foo`
8484
- `/kick Foo` - Force `Foo` disconnection until page reload
8585
- `/dump` - Download state dump to report issues
86+
- `/crash` - Crash server if you need to test your auto-restart solution
8687

8788
## Plugins
8889
- [octosubs](https://github.com/RblSb/SyncTube-octosubs) - More colorful `ASS`/`SSA` subtitles support

build/server.js

Lines changed: 37 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

res/client.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Types.hx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,4 +296,5 @@ enum abstract WsEventType(String) {
296296
var UpdatePlaylist;
297297
var TogglePlaylistLock;
298298
var Dump;
299+
var CrashTest;
299300
}

src/client/Main.hx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,8 @@ class Main {
697697

698698
case Dump:
699699
Utils.saveFile("dump.json", ApplicationJson, data.dump.data);
700+
701+
case CrashTest:
700702
}
701703
}
702704

@@ -1344,6 +1346,9 @@ class Main {
13441346
case "dump":
13451347
send({type: Dump});
13461348
return true;
1349+
case "crash":
1350+
send({type: CrashTest});
1351+
return true;
13471352
}
13481353
if (matchSimpleDate.match(command)) {
13491354
send({

src/server/ConsoleInput.hx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class ConsoleInput {
5757
output: process.stdout,
5858
completer: onCompletion
5959
});
60+
final originalTrace = haxe.Log.trace;
6061
haxe.Log.trace = (msg:Dynamic, ?infos:haxe.PosInfos) -> {
6162
Readline.clearLine(process.stdout, 0);
6263
Readline.cursorTo(process.stdout, 0, null);
@@ -68,7 +69,9 @@ class ConsoleInput {
6869
parseLine(line);
6970
rl.prompt();
7071
});
71-
// rl.on("close", exit);
72+
rl.on("close", () -> {
73+
haxe.Log.trace = originalTrace;
74+
});
7275
}
7376

7477
function formatOutput(v:Dynamic, infos:haxe.PosInfos):String {

src/server/Main.hx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,11 @@ class Main {
10321032
data: json
10331033
}
10341034
});
1035+
case CrashTest:
1036+
if (!client.isAdmin) return;
1037+
trace("Crashing...");
1038+
final arr:Array<Int> = cast null;
1039+
arr[1]++;
10351040
}
10361041
}
10371042

src/server/cache/Cache.hx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ class Cache {
2828
youtubeCache = new YoutubeCache(main, this);
2929
rawCache = new RawCache(main, this);
3030
isYtReady = youtubeCache.checkYtDeps();
31-
if (isYtReady) youtubeCache.cleanYtInputFiles();
31+
if (isYtReady) {
32+
youtubeCache.cleanYtInputFiles();
33+
youtubeCache.checkUpdate();
34+
}
3235
}
3336

3437
public function getCachedFiles():Array<String> {

src/server/cache/YoutubeCache.hx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ class YoutubeCache {
2929
}
3030
}
3131

32+
public function checkUpdate():Void {
33+
ytDlp.execAsync("-U", {
34+
onData: d -> {
35+
trace(d);
36+
}
37+
}).catchError(e -> {
38+
trace(e);
39+
});
40+
}
41+
3242
public function cleanYtInputFiles(prefix = "__tmp"):Void {
3343
final names = FileSystem.readDirectory(cache.cacheDir);
3444
for (name in names) {

0 commit comments

Comments
 (0)