Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

22
LINES

< > BotCompany Repo | #1013937 // autoRestartModule - auto-restart hotwired module on server change

JavaX fragment (include)

1  
static new ThreadLocal<Double> autoRestartModule_checkInterval;
2  
3  
static java.util.Timer autoRestartModule(fS moduleVar, fS programID, final bool callMain) {
4  
  ret autoRestartModule(moduleVar, programID, callMain, null);
5  
}
6  
7  
static java.util.Timer autoRestartModule(fS moduleVar, fS programID, final bool callMain, fO afterReload) {
8  
  ret doEvery_daemon(optPar(autoRestartModule_checkInterval, 10.0), new Runnable {
9  
    Var<S> name = evaluateInBackground(func -> S { snippetWithTitle(programID) });
10  
    S localMD5 = serverAutoRestartMD5(programID);
11  
    
12  
    public void run() {
13  
      S newMD5 = serverAutoRestartMD5(programID);
14  
      //print("MD5: " + localMD5 + " -> " + newMD5);
15  
      if (isMD5(newMD5) && neq(localMD5, newMD5)) {
16  
        localMD5 = newMD5;
17  
        S _name = name.has() ? name! : fsI(programID);
18  
        upgradeModuleVar(moduleVar, programID, _name, callMain, afterReload);
19  
      }
20  
    }
21  
  });
22  
}

Author comment

Began life as a copy of #1010683

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1013937
Snippet name: autoRestartModule - auto-restart hotwired module on server change
Eternal ID of this version: #1013937/22
Text MD5: fe5ae96f5f52fecabe3df5bb3a3ab651
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-05-20 23:57:30
Source code size: 933 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 447 / 491
Version history: 21 change(s)
Referenced in: [show references]