- commit
- 6503633
- parent
- c9b9480
- author
- Antonio Mika
- date
- 2024-10-11 18:03:02 +0000 UTC
Add logger and prom to imgs
1 files changed,
+10,
-9
+10,
-9
1@@ -18,6 +18,7 @@ import (
2 "syscall"
3 "time"
4
5+ "github.com/charmbracelet/promwish"
6 "github.com/charmbracelet/ssh"
7 "github.com/charmbracelet/wish"
8 "github.com/google/uuid"
9@@ -25,6 +26,7 @@ import (
10 "github.com/picosh/pico/db/postgres"
11 "github.com/picosh/pico/shared"
12 "github.com/picosh/pico/shared/storage"
13+ wsh "github.com/picosh/pico/wish"
14 psub "github.com/picosh/pubsub"
15 "github.com/picosh/tunkit"
16 "github.com/picosh/utils"
17@@ -251,14 +253,9 @@ func createServeMux(handler *CliHandler, pubsub psub.PubSub) func(ctx ssh.Contex
18 }
19
20 func StartSshServer() {
21- host := os.Getenv("SSH_HOST")
22- if host == "" {
23- host = "0.0.0.0"
24- }
25- port := os.Getenv("SSH_PORT")
26- if port == "" {
27- port = "2222"
28- }
29+ host := utils.GetEnv("IMGS_HOST", "0.0.0.0")
30+ port := utils.GetEnv("IMGS_SSH_PORT", "2222")
31+ promPort := utils.GetEnv("IMGS_PROM_PORT", "9222")
32 dbUrl := os.Getenv("DATABASE_URL")
33 registryUrl := utils.GetEnv("REGISTRY_URL", "0.0.0.0:5000")
34 minioUrl := utils.GetEnv("MINIO_URL", "http://0.0.0.0:9000")
35@@ -286,7 +283,11 @@ func StartSshServer() {
36 wish.WithAddress(fmt.Sprintf("%s:%s", host, port)),
37 wish.WithHostKeyPath("ssh_data/term_info_ed25519"),
38 wish.WithPublicKeyAuth(AuthHandler(dbh, logger)),
39- wish.WithMiddleware(WishMiddleware(handler)),
40+ wish.WithMiddleware(
41+ WishMiddleware(handler),
42+ promwish.Middleware(fmt.Sprintf("%s:%s", host, promPort), "imgs-ssh"),
43+ wsh.LogMiddleware(logger),
44+ ),
45 tunkit.WithWebTunnel(
46 tunkit.NewWebTunnelHandler(createServeMux(handler, pubsub), logger),
47 ),