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)

static new ThreadLocal<Double> autoRestartModule_checkInterval;

static java.util.Timer autoRestartModule(fS moduleVar, fS programID, final bool callMain) {
  ret autoRestartModule(moduleVar, programID, callMain, null);
}

static java.util.Timer autoRestartModule(fS moduleVar, fS programID, final bool callMain, fO afterReload) {
  ret doEvery_daemon(optPar(autoRestartModule_checkInterval, 10.0), new Runnable {
    Var<S> name = evaluateInBackground(func -> S { snippetWithTitle(programID) });
    S localMD5 = serverAutoRestartMD5(programID);
    
    public void run() {
      S newMD5 = serverAutoRestartMD5(programID);
      //print("MD5: " + localMD5 + " -> " + newMD5);
      if (isMD5(newMD5) && neq(localMD5, newMD5)) {
        localMD5 = newMD5;
        S _name = name.has() ? name! : fsI(programID);
        upgradeModuleVar(moduleVar, programID, _name, callMain, afterReload);
      }
    }
  });
}

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: 375 / 409
Version history: 21 change(s)
Referenced in: [show references]