Skip to content

Commit

Permalink
refactor: use aria2 --stop-with-process
Browse files Browse the repository at this point in the history
  • Loading branch information
3Shain committed Mar 8, 2023
1 parent 51d16b1 commit 9cb93ea
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { createCommonUpdateUI } from "./common-update-ui";

export async function createApp() {

await setKey("singleton", null);

let aria2_port = 6868;

Expand All @@ -37,7 +38,8 @@ export async function createApp() {
const github = await createGithubEndpoint();
const aria2_session = await resolve("./aria2.session");
await appendFile(aria2_session, "");
const pid = await spawn("./sidecar/aria2/aria2c", [
const pid = (await exec("echo", ["$PPID"])).stdOut.split("\n")[0];
await spawn("./sidecar/aria2/aria2c", [
// "-q",
"-d",
"/",
Expand All @@ -53,12 +55,9 @@ export async function createApp() {
`"${aria2_session}"`,
`--pause`,
`true`,
"--stop-with-process",
pid,
]);
addTerminationHook(async () => {
await log("killing process " + pid);
await exec("kill", [pid + ""]);
return true;
});
const aria2 = await Promise.race([
createAria2({ host: "127.0.0.1", port: aria2_port }),
timeout(10000),
Expand Down

0 comments on commit 9cb93ea

Please sign in to comment.