repos / pico

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

pico / cmd / pgs / web
Eric Bower  ·  2026-01-25

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)
12
13func main() {
14	dbURL := shared.GetEnv("DATABASE_URL", "")
15	withPipe := strings.ToLower(shared.GetEnv("PICO_PIPE_ENABLED", "true")) == "true"
16	logger := shared.CreateLogger("pgs-web", withPipe)
17	dbpool, err := pgsdb.NewDB(dbURL, logger)
18	if err != nil {
19		panic(err)
20	}
21	adapter := storage.GetStorageTypeFromEnv()
22	st, err := storage.NewStorage(logger, adapter)
23	if err != nil {
24		panic(err)
25	}
26	ctx := context.Background()
27	drain := pgs.CreateSubCacheDrain(ctx, logger)
28	pubsub := pgs.NewPubsubPipe(drain)
29	defer func() {
30		_ = pubsub.Close()
31	}()
32	cfg := pgs.NewPgsConfig(logger, dbpool, st, pubsub)
33	pgs.StartApiServer(cfg)
34}