aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2024-06-01 10:24:16 -0400
committerXe Iaso <me@xeiaso.net>2024-06-01 10:24:16 -0400
commita7d92cbcbf7adcbfa9fede098608a082519f945c (patch)
tree24d6098fc62f581d1949720870910ac834193c40 /cmd
parent05a922d8f3ae57e47426b81769fe168255cda03e (diff)
downloadx-a7d92cbcbf7adcbfa9fede098608a082519f945c.tar.xz
x-a7d92cbcbf7adcbfa9fede098608a082519f945c.zip
cmd/azurda: oh my god it works???
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/azurda/fly.toml27
-rw-r--r--cmd/azurda/main.go28
-rw-r--r--cmd/azurda/yeetfile.js4
-rw-r--r--cmd/xedn/fly.toml7
4 files changed, 60 insertions, 6 deletions
diff --git a/cmd/azurda/fly.toml b/cmd/azurda/fly.toml
new file mode 100644
index 0000000..aa33611
--- /dev/null
+++ b/cmd/azurda/fly.toml
@@ -0,0 +1,27 @@
+# fly.toml app configuration file generated for azurda on 2024-06-01T09:44:12-04:00
+#
+# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
+#
+
+app = 'azurda'
+primary_region = 'yyz'
+
+[build]
+ image = "registry.fly.io/azurda:latest"
+
+[http_service]
+ internal_port = 8085
+ force_https = true
+ auto_stop_machines = true
+ auto_start_machines = true
+ min_machines_running = 0
+ processes = ['app']
+
+[[vm]]
+ memory = '512mb'
+ cpu_kind = 'shared'
+ cpus = 1
+
+[[metrics]]
+ port = 8086
+ path = "/metrics"
diff --git a/cmd/azurda/main.go b/cmd/azurda/main.go
index 62cd43e..2daab97 100644
--- a/cmd/azurda/main.go
+++ b/cmd/azurda/main.go
@@ -5,13 +5,13 @@ package main
import (
"bytes"
+ "context"
"embed"
"flag"
"fmt"
"image"
"image/jpeg"
_ "image/png"
- "log"
"log/slog"
"net/http"
"os"
@@ -20,6 +20,8 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
+ "github.com/prometheus/client_golang/prometheus/promhttp"
+ "golang.org/x/sync/errgroup"
"within.website/x/internal"
"within.website/x/web/stablediffusion"
)
@@ -89,15 +91,31 @@ func main() {
http.ServeFileFS(w, r, static, "static/index.html")
})
mux.Handle("/static/", http.FileServerFS(static))
- mux.HandleFunc("GET /fallthrough/{hash}", ServeStableDiffusion)
+ mux.HandleFunc("GET fallthrough.azurda.within.website/{hash}", ServeStableDiffusion)
- log.Fatal(http.ListenAndServe(*bind, mux))
+ http.Handle("/metrics", promhttp.Handler())
+
+ g, _ := errgroup.WithContext(context.Background())
+
+ g.Go(func() error {
+ slog.Info("starting internal server", "bind", *internalBind)
+ return http.ListenAndServe(*internalBind, nil)
+ })
+
+ g.Go(func() error {
+ slog.Info("starting server", "bind", *bind)
+ return http.ListenAndServe(*bind, SpewMiddleware(mux))
+ })
+
+ if err := g.Wait(); err != nil {
+ slog.Error("error doing work", "err", err)
+ os.Exit(1)
+ }
}
func SpewMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- r.Write(os.Stdout)
- fmt.Println()
+ slog.Info("got request", "method", r.Method, "url", r.URL.String(), "headers", r.Header)
next.ServeHTTP(w, r)
})
}
diff --git a/cmd/azurda/yeetfile.js b/cmd/azurda/yeetfile.js
new file mode 100644
index 0000000..8a1d062
--- /dev/null
+++ b/cmd/azurda/yeetfile.js
@@ -0,0 +1,4 @@
+nix.build(".#docker.azurda")
+docker.load("./result")
+docker.push("registry.fly.io/azurda:latest")
+fly.deploy()
diff --git a/cmd/xedn/fly.toml b/cmd/xedn/fly.toml
index dac47b6..97c18ad 100644
--- a/cmd/xedn/fly.toml
+++ b/cmd/xedn/fly.toml
@@ -28,6 +28,11 @@ url_prefix = "/file/christine-static"
guest_path = "/"
tigris_bucket = "xedn"
+[[statics]]
+url_prefix = "/avatar"
+guest_path = "/"
+tigris_bucket = "azurda"
+
[[services]]
protocol = "tcp"
internal_port = 8080
@@ -52,5 +57,5 @@ timeout = "2s"
grace_period = "1s"
[[metrics]]
-port = 8081
+port = 8086
path = "/metrics"