Monorepo for Tangled tangled.org

nix,spindle: use DATA_DIR for db & other spindle data #983

open opened by boltless.me targeting master from sl/spindle-rewrite

This single persistent directory can be used for storing general spindle data like db, motd file and upcoming sparse-clone git repos.

db path will be ${DATA_DIR}/spindle.db

Signed-off-by: Seongmin Lee git@boltless.me

Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:xasnlahkri4ewmbuzly2rlc5/sh.tangled.repo.pull/3mckguakf7d22
+11 -6
Diff #4
+4 -4
nix/modules/spindle.nix
··· 25 25 description = "Address to listen on"; 26 26 }; 27 27 28 - dbPath = mkOption { 28 + stateDir = mkOption { 29 29 type = types.path; 30 - default = "/var/lib/spindle/spindle.db"; 31 - description = "Path to the database file"; 30 + default = "/var/lib/spindle"; 31 + description = "Tangled spindle data directory"; 32 32 }; 33 33 34 34 hostname = mkOption { ··· 137 137 StateDirectory = "spindle"; 138 138 Environment = [ 139 139 "SPINDLE_SERVER_LISTEN_ADDR=${cfg.server.listenAddr}" 140 - "SPINDLE_SERVER_DB_PATH=${cfg.server.dbPath}" 140 + "SPINDLE_SERVER_DATA_DIR=${cfg.server.stateDir}" 141 141 "SPINDLE_SERVER_HOSTNAME=${cfg.server.hostname}" 142 142 "SPINDLE_SERVER_PLC_URL=${cfg.server.plcUrl}" 143 143 "SPINDLE_SERVER_RELAY_URL=${cfg.server.relayUrl}"
+1 -1
nix/vm.nix
··· 140 140 }; 141 141 in { 142 142 knot = mkDataSyncScripts "/mnt/knot-data" config.services.tangled.knot.stateDir; 143 - spindle = mkDataSyncScripts "/mnt/spindle-data" (builtins.dirOf config.services.tangled.spindle.server.dbPath); 143 + spindle = mkDataSyncScripts "/mnt/spindle-data" config.services.tangled.spindle.server.stateDir; 144 144 }; 145 145 }) 146 146 ];
+6 -1
spindle/config/config.go
··· 3 3 import ( 4 4 "context" 5 5 "fmt" 6 + "path/filepath" 6 7 7 8 "github.com/bluesky-social/indigo/atproto/syntax" 8 9 "github.com/sethvargo/go-envconfig" ··· 10 11 11 12 type Server struct { 12 13 ListenAddr string `env:"LISTEN_ADDR, default=0.0.0.0:6555"` 13 - DBPath string `env:"DB_PATH, default=spindle.db"` 14 14 Hostname string `env:"HOSTNAME, required"` 15 15 TapDBUrl string `env:"TAP_DB_URL, default=sqlite://./spindle-tap.db"` 16 16 TapPort string `env:"TAP_PORT, default=6480"` ··· 20 20 Owner syntax.DID `env:"OWNER, required"` 21 21 Secrets Secrets `env:",prefix=SECRETS_"` 22 22 LogDir string `env:"LOG_DIR, default=/var/log/spindle"` 23 + DataDir string `env:"DATA_DIR, default=/var/lib/spindle"` 23 24 QueueSize int `env:"QUEUE_SIZE, default=100"` 24 25 MaxJobCount int `env:"MAX_JOB_COUNT, default=2"` // max number of jobs that run at a time 25 26 } ··· 28 29 return syntax.DID(fmt.Sprintf("did:web:%s", s.Hostname)) 29 30 } 30 31 32 + func (s Server) DBPath() string { 33 + return filepath.Join(s.DataDir, "spindle.db") 34 + } 35 + 31 36 type Secrets struct { 32 37 Provider string `env:"PROVIDER, default=sqlite"` 33 38 OpenBao OpenBaoConfig `env:",prefix=OPENBAO_"`

History

5 rounds 0 comments
sign up or login to add to the discussion
1 commit
expand
nix,spindle: use DATA_DIR for db & other spindle data
2/3 failed, 1/3 success
expand
merge conflicts detected
expand
  • appview/state/state.go:35
  • go.mod:9
  • go.sum:483
expand 0 comments
1 commit
expand
nix,spindle: use DATA_DIR for db & other spindle data
2/3 failed, 1/3 success
expand
expand 0 comments
1 commit
expand
nix,spindle: use DATA_DIR for db & other spindle data
2/3 failed, 1/3 success
expand
expand 0 comments
1 commit
expand
nix,spindle: use DATA_DIR for db & other spindle data
2/3 failed, 1/3 success
expand
expand 0 comments
1 commit
expand
nix,spindle: use DATA_DIR for db & other spindle data
2/3 failed, 1/3 success
expand
expand 0 comments