Skip to content

Commit

Permalink
Add logger and prom to imgs
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniomika committed Oct 11, 2024
1 parent c9b9480 commit 6503633
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions imgs/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ import (
"syscall"
"time"

"github.com/charmbracelet/promwish"
"github.com/charmbracelet/ssh"
"github.com/charmbracelet/wish"
"github.com/google/uuid"
"github.com/picosh/pico/db"
"github.com/picosh/pico/db/postgres"
"github.com/picosh/pico/shared"
"github.com/picosh/pico/shared/storage"
wsh "github.com/picosh/pico/wish"
psub "github.com/picosh/pubsub"
"github.com/picosh/tunkit"
"github.com/picosh/utils"
Expand Down Expand Up @@ -251,14 +253,9 @@ func createServeMux(handler *CliHandler, pubsub psub.PubSub) func(ctx ssh.Contex
}

func StartSshServer() {
host := os.Getenv("SSH_HOST")
if host == "" {
host = "0.0.0.0"
}
port := os.Getenv("SSH_PORT")
if port == "" {
port = "2222"
}
host := utils.GetEnv("IMGS_HOST", "0.0.0.0")
port := utils.GetEnv("IMGS_SSH_PORT", "2222")
promPort := utils.GetEnv("IMGS_PROM_PORT", "9222")
dbUrl := os.Getenv("DATABASE_URL")
registryUrl := utils.GetEnv("REGISTRY_URL", "0.0.0.0:5000")
minioUrl := utils.GetEnv("MINIO_URL", "http://0.0.0.0:9000")
Expand Down Expand Up @@ -286,7 +283,11 @@ func StartSshServer() {
wish.WithAddress(fmt.Sprintf("%s:%s", host, port)),
wish.WithHostKeyPath("ssh_data/term_info_ed25519"),
wish.WithPublicKeyAuth(AuthHandler(dbh, logger)),
wish.WithMiddleware(WishMiddleware(handler)),
wish.WithMiddleware(
WishMiddleware(handler),
promwish.Middleware(fmt.Sprintf("%s:%s", host, promPort), "imgs-ssh"),
wsh.LogMiddleware(logger),
),
tunkit.WithWebTunnel(
tunkit.NewWebTunnelHandler(createServeMux(handler, pubsub), logger),
),
Expand Down

0 comments on commit 6503633

Please sign in to comment.