no infinite loops today
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"deploy-self": "bun run src/scripts/deploySelf.ts",
|
"deploy-self": "bun run src/scripts/deploySelf.ts",
|
||||||
"dev": "NODE_ENV=development PORT=6001 bun run --hot src/index.ts",
|
"dev": "NODE_ENV=development PORT=6001 bun run --hot src/index.ts",
|
||||||
"build": "bun run src/scripts/reloadCaddy.ts",
|
"build": "bun run src/scripts/rebuildCaddy.ts",
|
||||||
"start": "NODE_ENV=production bun run src/index.ts"
|
"start": "NODE_ENV=production bun run src/index.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { indexedConfig, config } from "./config";
|
import { indexedConfig, config } from "./config";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
import { $ } from "bun";
|
||||||
|
|
||||||
export const reloadCaddyfile = () => {
|
export const caddyfilePath = (host: string) =>
|
||||||
const caddyfilePath = (host: string) =>
|
|
||||||
path.join(config.directory, host, "src", "Caddyfile");
|
path.join(config.directory, host, "src", "Caddyfile");
|
||||||
|
|
||||||
|
export const rebuildCaddyfile = async () => {
|
||||||
|
// we have to delete our own caddyfile first or we'll
|
||||||
|
// accidentally import ourselves in the new Caddyfile
|
||||||
|
await $`rm ${caddyfilePath("deployer2")}`.nothrow();
|
||||||
|
|
||||||
const Caddyfile = Object.values(indexedConfig)
|
const Caddyfile = Object.values(indexedConfig)
|
||||||
.map(
|
.map(
|
||||||
({ host, port }) => `
|
({ host, port }) => `
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { $ } from "bun";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import { config, indexedConfig } from "./config";
|
import { config, indexedConfig } from "./config";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { reloadCaddyfile } from "./caddy";
|
import { rebuildCaddyfile } from "./caddy";
|
||||||
|
|
||||||
type DeployInstance = {
|
type DeployInstance = {
|
||||||
host: string;
|
host: string;
|
||||||
@@ -33,7 +33,7 @@ export const deploy = async ({ host, commitHash }: DeployInstance) => {
|
|||||||
|
|
||||||
// Build
|
// Build
|
||||||
await $`make build`;
|
await $`make build`;
|
||||||
reloadCaddyfile();
|
rebuildCaddyfile();
|
||||||
|
|
||||||
// Register service
|
// Register service
|
||||||
const systemdServiceName = `deployer2-${host}.service`;
|
const systemdServiceName = `deployer2-${host}.service`;
|
||||||
|
|||||||
3
src/scripts/rebuildCaddy.ts
Normal file
3
src/scripts/rebuildCaddy.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import { rebuildCaddyfile } from "../caddy";
|
||||||
|
|
||||||
|
rebuildCaddyfile();
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { reloadCaddyfile } from "../caddy";
|
|
||||||
|
|
||||||
reloadCaddyfile();
|
|
||||||
Reference in New Issue
Block a user