mirror of
https://github.com/MercuryWorkshop/adrift.git
synced 2025-05-12 22:00:02 -04:00
autoupdater restarting logic
This commit is contained in:
parent
006ee121ab
commit
08a4137071
2 changed files with 28 additions and 3 deletions
|
@ -193,7 +193,11 @@
|
||||||
<div id="topbar" class="flex justify-between items-center p-4">
|
<div id="topbar" class="flex justify-between items-center p-4">
|
||||||
<div id="logo">
|
<div id="logo">
|
||||||
<Card type="">
|
<Card type="">
|
||||||
<img height="100" width="100" src={logo} />
|
<div class="flex items-center text-3xl">
|
||||||
|
<Icon icon="material-symbols:sailing" />
|
||||||
|
<p class="text-2xl ml-3">Adrift</p>
|
||||||
|
</div>
|
||||||
|
<!-- <img height="100" width="100" src={logo} /> -->
|
||||||
<!-- <h3 class="text-xl">(logo goes here)</h3> -->
|
<!-- <h3 class="text-xl">(logo goes here)</h3> -->
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { datadir } from "./lib";
|
||||||
import { spawn } from "child_process";
|
import { spawn } from "child_process";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { https } from 'follow-redirects';
|
import { https } from 'follow-redirects';
|
||||||
|
import chalk from "chalk";
|
||||||
let dir = datadir();
|
let dir = datadir();
|
||||||
let platform = `${process.platform}-${process.arch}`
|
let platform = `${process.platform}-${process.arch}`
|
||||||
let appname = `adrift-server-${platform}`;
|
let appname = `adrift-server-${platform}`;
|
||||||
|
@ -18,7 +19,27 @@ https.get(
|
||||||
fs.chmodSync(`${dir}/${appname}`, "755");
|
fs.chmodSync(`${dir}/${appname}`, "755");
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// this timeout shouldn't be needed, but it is
|
// this timeout shouldn't be needed, but it is
|
||||||
spawn(`${dir}/${appname}`, [], { stdio: "inherit" });
|
start();
|
||||||
}, 2000);
|
}, 2000);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function start() {
|
||||||
|
console.log(chalk.blue(`Starting adrift...`));
|
||||||
|
|
||||||
|
let child = spawn(`${dir}/${appname}`, [], { stdio: ["inherit", "inherit", "pipe"] });
|
||||||
|
|
||||||
|
let errbuf = "";
|
||||||
|
|
||||||
|
child.stderr!.on("data", e => {
|
||||||
|
let err = e.toString();
|
||||||
|
console.error(err);
|
||||||
|
errbuf += err;
|
||||||
|
});
|
||||||
|
child.on("exit", (e) => {
|
||||||
|
// upload `err` as telemetry?
|
||||||
|
console.log(chalk.red(`Adrift crashed! exit code ${e}`));
|
||||||
|
console.log(chalk.green("restarting in 3 seconds"));
|
||||||
|
setTimeout(start, 3000);
|
||||||
|
});
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue