-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #790 from Shelf-nu/hono-deploy-fix
Hono deploy fix
- Loading branch information
Showing
3 changed files
with
47 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,17 @@ | ||
// learn more: https://fly.io/docs/reference/configuration/#services-http_checks | ||
import type { LoaderFunctionArgs } from "@remix-run/node"; | ||
import { json } from "@remix-run/node"; | ||
|
||
import { db } from "~/database"; | ||
|
||
export async function loader({ request }: LoaderFunctionArgs) { | ||
const host = | ||
request.headers.get("X-Forwarded-Host") ?? request.headers.get("host"); | ||
|
||
export async function loader() { | ||
try { | ||
const url = new URL("/", `http://${host}`); | ||
// if we can connect to the database and make a simple query | ||
// and make a HEAD request to ourselves, then we're good. | ||
await Promise.all([ | ||
db.user.findFirst(), | ||
fetch(url.toString(), { method: "HEAD" }).then((r) => { | ||
if (!r.ok) return Promise.reject(r); | ||
}), | ||
]); | ||
return new Response("OK"); | ||
await db.user.findFirst(); | ||
return json({ status: "OK" }); | ||
} catch (error: unknown) { | ||
// eslint-disable-next-line no-console | ||
console.log("healthcheck ❌", { error }); | ||
return new Response("ERROR", { status: 500 }); | ||
return json({ status: "ERROR" }, { status: 500 }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,46 @@ | ||
app = "shelf-webapp" | ||
|
||
primary_region = "ams" | ||
kill_signal = "SIGINT" | ||
kill_timeout = 5 | ||
processes = [] | ||
kill_timeout = "5s" | ||
swap_size_mb = 512 | ||
|
||
[experimental] | ||
auto_rollback = true | ||
|
||
[deploy] | ||
strategy = "bluegreen" | ||
|
||
[env] | ||
PORT = "8080" | ||
NODE_ENV = "production" | ||
NODE_ENV = "production" | ||
PORT = "8080" | ||
|
||
[[services.ports]] | ||
handlers = ["http"] | ||
port = 80 | ||
force_https = true | ||
|
||
[[services.ports]] | ||
handlers = ["tls", "http"] | ||
port = 443 | ||
|
||
[http_service] | ||
internal_port = 8080 | ||
force_https = true | ||
auto_stop_machines = false | ||
auto_start_machines = false | ||
min_machines_running = 1 | ||
processes = ["app"] | ||
|
||
[http_service.concurrency] | ||
type = "requests" | ||
soft_limit = 100 | ||
hard_limit = 125 | ||
|
||
[[http_service.checks]] | ||
grace_period = "5s" | ||
interval = "10s" | ||
method = "GET" | ||
timeout = "2s" | ||
path = "/healthcheck" | ||
protocol = "http" | ||
|
||
[experimental] | ||
allowed_public_ports = [] | ||
auto_rollback = true | ||
cmd = "start.sh" | ||
entrypoint = "sh" | ||
|
||
[[services]] | ||
internal_port = 8080 | ||
processes = ["app"] | ||
protocol = "tcp" | ||
script_checks = [] | ||
|
||
[services.concurrency] | ||
hard_limit = 125 | ||
soft_limit = 100 | ||
type = "connections" | ||
|
||
[[services.ports]] | ||
handlers = ["http"] | ||
port = 80 | ||
force_https = true | ||
|
||
[[services.ports]] | ||
handlers = ["tls", "http"] | ||
port = 443 | ||
|
||
[[services.tcp_checks]] | ||
grace_period = "1s" | ||
interval = "15s" | ||
restart_limit = 0 | ||
timeout = "2s" | ||
|
||
[[services.http_checks]] | ||
interval = "10s" | ||
grace_period = "5s" | ||
method = "get" | ||
path = "/healthcheck" | ||
protocol = "http" | ||
timeout = "2s" | ||
tls_skip_verify = false | ||
[services.http_checks.headers] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters