1 | static double autoRestart_interval = 10; |
2 | static bool autoRestart_on, autoRestart_debug, autoRestart_simulate; |
3 | static java.util.Timer autoRestart_timer; |
4 | |
5 | static void autoRestart(double interval) { |
6 | autoRestart_interval = interval; |
7 | autoRestart(); |
8 | } |
9 | |
10 | static void autoRestart() { |
11 | if (!isMain() || autoRestart_on || vmHasResourceLoader()) ret; |
12 | set autoRestart_on; |
13 | autoRestart_schedule(); |
14 | preloadProgramTitle(); |
15 | } |
16 | |
17 | static void autoRestart_off() { |
18 | if (!autoRestart_on) ret; |
19 | stopTimer(autoRestart_timer); |
20 | autoRestart_timer = null; |
21 | } |
22 | |
23 | svoid autoRestart_schedule { |
24 | autoRestart_timer = doLater_daemon(toMS(autoRestart_interval), r autoRestart_check); |
25 | } |
26 | |
27 | svoid autoRestart_check { |
28 | try { |
29 | S newMD5; |
30 | try { |
31 | newMD5 = serverAutoRestartMD5(programID()); |
32 | } catch e { |
33 | ret; |
34 | } |
35 | if (!isMD5(newMD5)) { if (autoRestart_debug) print("autoRestart: no server transpilation"); ret; } |
36 | if (autoRestart_localMD5 == null) |
37 | autoRestart_localMD5 = md5(loadCachedTranspilation(programID())); |
38 | |
39 | S localMD5 = autoRestart_localMD5(); |
40 | if (neq(localMD5, newMD5)) { |
41 | if (autoRestart_simulate) |
42 | print("Would upgrade now. " + localMD5 + " -> " + newMD5); |
43 | else { |
44 | infoBox("Upgrading " + programTitle()); |
45 | restartWithDelay(500); |
46 | sleep(); |
47 | } |
48 | } |
49 | } finally { |
50 | if (autoRestart_debug) print("autoRestart: Done"); |
51 | autoRestart_schedule(); |
52 | } |
53 | } |
Began life as a copy of #1010663
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1010683 |
Snippet name: | autoRestart - auto-restart program on server change |
Eternal ID of this version: | #1010683/25 |
Text MD5: | 02c38d3614fe1f1acceab6fbec9880a0 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-02-28 18:17:12 |
Source code size: | 1467 bytes / 53 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 627 / 747 |
Version history: | 24 change(s) |
Referenced in: | [show references] |