repos / pico

pico services mono repo
git clone https://github.com/picosh/pico.git

pico / cmd / pgs / ssh
Eric Bower  ·  2025-07-04

main.go

 1package main
 2
 3import (
 4	"context"
 5	"strings"
 6
 7	"github.com/picosh/pico/pkg/apps/pgs"
 8	pgsdb "github.com/picosh/pico/pkg/apps/pgs/db"
 9	"github.com/picosh/pico/pkg/shared"
10	"github.com/picosh/pico/pkg/shared/storage"
11	"github.com/picosh/utils"
12)
13
14func main() {
15	dbURL := utils.GetEnv("DATABASE_URL", "")
16	withPipe := strings.ToLower(utils.GetEnv("PICO_PIPE_ENABLED", "true")) == "true"
17	logger := shared.CreateLogger("pgs-ssh", withPipe)
18	dbpool, err := pgsdb.NewDB(dbURL, logger)
19	if err != nil {
20		panic(err)
21	}
22	adapter := storage.GetStorageTypeFromEnv()
23	st, err := storage.NewStorage(logger, adapter)
24	if err != nil {
25		panic(err)
26	}
27	ctx := context.Background()
28	drain := pgs.CreatePubCacheDrain(ctx, logger)
29	pubsub := pgs.NewPubsubPipe(drain)
30	defer func() {
31		_ = pubsub.Close()
32	}()
33	cfg := pgs.NewPgsConfig(logger, dbpool, st, pubsub)
34	killCh := make(chan error)
35	pgs.StartSshServer(cfg, killCh)
36}