-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdaemon.ts
More file actions
72 lines (67 loc) · 2.04 KB
/
daemon.ts
File metadata and controls
72 lines (67 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import {
daemonRestart,
daemonStart,
daemonStatus,
daemonStop,
} from "@array/core/commands/daemon";
import { cyan, dim, formatSuccess, green, message, red } from "../utils/output";
import { unwrap } from "../utils/run";
export async function daemon(subcommand: string): Promise<void> {
switch (subcommand) {
case "start": {
unwrap(await daemonStart());
message(formatSuccess("Daemon started"));
message(dim(" Watching workspaces for file changes"));
message(dim(" Stop with: arr daemon stop"));
break;
}
case "stop": {
unwrap(await daemonStop());
message(formatSuccess("Daemon stopped"));
break;
}
case "restart": {
unwrap(await daemonRestart());
message(formatSuccess("Daemon restarted"));
break;
}
case "status": {
const status = unwrap(await daemonStatus());
if (status.running) {
message(
`${green("●")} Daemon is ${green("running")} (PID: ${status.pid})`,
);
if (status.repos.length > 0) {
message("");
message("Watching repos:");
for (const repo of status.repos) {
message(` ${dim(repo.path)}`);
for (const ws of repo.workspaces) {
message(` └─ ${ws}`);
}
}
} else {
message("");
message(
dim("No repos registered. Use arr preview to register workspaces."),
);
}
message("");
message(`Logs: ${dim(status.logPath)}`);
} else {
message(`${red("○")} Daemon is ${dim("not running")}`);
message("");
message(`Start with: ${cyan("arr daemon start")}`);
}
break;
}
default:
message("Usage: arr daemon <start|stop|restart|status>");
message("");
message("Subcommands:");
message(" start Start the workspace sync daemon");
message(" stop Stop the daemon");
message(" restart Restart the daemon");
message(" status Check if daemon is running");
}
}