autoupdater restarting logic

This commit is contained in:
CoolElectronics 2023-08-20 09:39:36 -04:00
parent 006ee121ab
commit 08a4137071
No known key found for this signature in database
GPG key ID: F63593D168636C50
2 changed files with 28 additions and 3 deletions

View file

@ -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>

View file

@ -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);
});
}