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

34
LINES

< > BotCompany Repo | #1010694 // autoRestart v1 - auto-restart program on server change

JavaX fragment (include)

static double autoRestart_interval = 10;
static bool autoRestart_on, autoRestart_debug;

static void autoRestart() {
  if (autoRestart_on) ret;
  set autoRestart_on;
  autoRestart_schedule();
  preloadProgramTitle();
}

svoid autoRestart_schedule {
  doLater_daemon(toMS(autoRestart_interval), f autoRestart_check);
}

svoid autoRestart_check {
  try {
    S newMD5 = getServerTranspilationMD5(programID());
    if (!isMD5(newMD5)) { if (autoRestart_debug) print("autoRestart: no server transpilation"); ret; }
    S localMD5 = md5(loadCachedTranspilation(programID()));

    if (neq(localMD5, newMD5)) {
      if (!hasServerDex(programID())) {
        if (autoRestart_debug) print("autoRestart: Compilation failed");
        ret;
      }
      infoBox("Upgrading " + programTitle());
      restartWithDelay(1000);
      sleep();
    }
  } finally {
    if (autoRestart_debug) print("autoRestart: Done");
    autoRestart_schedule();
  }
}

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: #1010694
Snippet name: autoRestart v1 - auto-restart program on server change
Eternal ID of this version: #1010694/1
Text MD5: c930aa0db132e44d688dd9111b53e053
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-09-25 19:30:09
Source code size: 971 bytes / 34 lines
Pitched / IR pitched: No / No
Views / Downloads: 403 / 454
Referenced in: [show references]