mirror of
https://github.com/hackclub/nest.git
synced 2025-01-05 02:36:40 +00:00
Migrate nest bot to new caddy manager
This commit is contained in:
parent
0e9e2ac22a
commit
85458fdf1c
4 changed files with 3 additions and 31 deletions
|
@ -1,14 +1,8 @@
|
|||
import { readFile, writeFile } from "fs/promises";
|
||||
import { exec, ExecException } from "child_process";
|
||||
import { exec, ExecException, execSync } from "child_process";
|
||||
|
||||
export async function add_root_caddyfile_config(username: string) {
|
||||
const templateConfig = (
|
||||
await readFile("./src/os/templates/root_caddyfile_config.txt")
|
||||
).toString("utf8");
|
||||
|
||||
const newConfig = templateConfig.replace(/<username>/g, username);
|
||||
|
||||
await writeFile("/etc/caddy/Caddyfile", newConfig, { flag: "a" });
|
||||
execSync(`nest caddy add ${username}.hackclub.app --user ${username}`)
|
||||
}
|
||||
|
||||
function log_output(err: ExecException | null, stdout: string, stderr: string) {
|
||||
|
|
|
@ -12,7 +12,6 @@ touch /var/lib/systemd/linger/$1
|
|||
export XDG_RUNTIME_DIR=/run/user/$(id -u $1)
|
||||
systemctl --user -M $1@ daemon-reload
|
||||
systemctl --user -M $1@ enable caddy
|
||||
systemctl reload caddy
|
||||
|
||||
# Limits
|
||||
setquota -u $1 15G 15G 0 0 /
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
<username>.hackclub.app {
|
||||
reverse_proxy unix//home/<username>/.webserver.sock {
|
||||
health_status 2xx
|
||||
health_interval 5s
|
||||
health_timeout 60s
|
||||
}
|
||||
handle_errors {
|
||||
@502 expression {err.status_code} == 502
|
||||
handle @502 {
|
||||
respond * 502 {
|
||||
body "This site is either down or does not exist.
|
||||
If this site really does exist, please make sure your Caddy is running. Try systemctl --user start caddy. It is also possible you have a config issue, if so, please reach out to us on the slack #nest.
|
||||
"
|
||||
}
|
||||
}
|
||||
respond "{err.status_code} | {err.status_text} (on {re.host.1})" {
|
||||
close
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
admin unix//home/<username>/caddy-admin.sock
|
||||
}
|
||||
http://<username>.hackclub.app {
|
||||
bind unix/.webserver.sock|777
|
||||
bind unix/.<username>.hackclub.app.webserver.sock|777
|
||||
root * /home/<username>/pub
|
||||
file_server {
|
||||
hide .git .env
|
||||
|
|
Loading…
Reference in a new issue