Skip to content

Commit 7adbbd0

Browse files
committed
Fix: bm2 startup doesn't provide a working service file #6
Fix: https://github.com/bun-bm2/bm2/issues/6
1 parent 7a279a7 commit 7adbbd0

1 file changed

Lines changed: 29 additions & 29 deletions

File tree

src/startup-manager.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,37 +35,37 @@
3535

3636
private generateSystemd(bunPath: string, bm2Path: string, daemonPath: string): string {
3737
const unit = `[Unit]
38-
Description=BM2 Process Manager
39-
Documentation=https://github.com/bm2
40-
After=network.target
41-
42-
[Service]
43-
Type=forking
44-
User=${process.env.USER || "root"}
45-
LimitNOFILE=infinity
46-
LimitNPROC=infinity
47-
LimitCORE=infinity
48-
Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${join(bunPath, "..")}
49-
Environment=BM2_HOME=${join(process.env.HOME || "/root", ".bm2")}
50-
PIDFile=${join(process.env.HOME || "/root", ".bm2", "daemon.pid")}
51-
Restart=on-failure
52-
53-
ExecStart=${bunPath} run ${daemonPath}
54-
ExecReload=${bunPath} run ${bm2Path} reload all
55-
ExecStop=${bunPath} run ${bm2Path} kill
56-
57-
[Install]
58-
WantedBy=multi-user.target`;
59-
38+
Description=BM2 Process Manager
39+
Documentation=https://github.com/bm2
40+
After=network.target
41+
42+
[Service]
43+
Type=simple
44+
User=${process.env.USER || "root"}
45+
LimitNOFILE=infinity
46+
LimitNPROC=infinity
47+
LimitCORE=infinity
48+
Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${join(bunPath, "..")}
49+
Environment=BM2_HOME=${join(process.env.HOME || "/root", ".bm2")}
50+
Restart=on-failure
51+
52+
ExecStart=${bunPath} run ${daemonPath}
53+
ExecStartPost=${bunPath} run ${bm2Path} resurrect
54+
ExecReload=${bunPath} run ${bm2Path} reload all
55+
ExecStop=${bunPath} run ${bm2Path} kill
56+
57+
[Install]
58+
WantedBy=multi-user.target`;
59+
6060
const servicePath = "/etc/systemd/system/bm2.service";
6161
return `# BM2 Systemd Service
62-
# Save to: ${servicePath}
63-
# Then run:
64-
# sudo systemctl daemon-reload
65-
# sudo systemctl enable bm2
66-
# sudo systemctl start bm2
67-
68-
${unit}`;
62+
# Save to: ${servicePath}
63+
# Then run:
64+
# sudo systemctl daemon-reload
65+
# sudo systemctl enable bm2
66+
# sudo systemctl start bm2
67+
68+
${unit}`;
6969
}
7070

7171
private generateLaunchd(bunPath: string, bm2Path: string, daemonPath: string): string {

0 commit comments

Comments
 (0)