This commit is contained in:
parent
025c829c68
commit
3af77b6bea
2 changed files with 9 additions and 5 deletions
|
@ -1,6 +1,5 @@
|
||||||
services:
|
services:
|
||||||
himbot:
|
server:
|
||||||
container_name: himbot
|
|
||||||
image: ${IMAGE}
|
image: ${IMAGE}
|
||||||
ports:
|
ports:
|
||||||
- "3117:3000"
|
- "3117:3000"
|
||||||
|
|
11
lib/db.go
11
lib/db.go
|
@ -18,11 +18,16 @@ var DBConnector *libsql.Connector
|
||||||
|
|
||||||
func InitDB() error {
|
func InitDB() error {
|
||||||
// Determine DB path based on /data directory existence
|
// Determine DB path based on /data directory existence
|
||||||
dbName := "file:./himbot.db"
|
var dbPath string
|
||||||
|
if _, err := os.Stat("/data"); os.IsNotExist(err) {
|
||||||
|
dbPath = "file:./himbot.db"
|
||||||
|
} else {
|
||||||
|
dbPath = "file:/data/himbot.db"
|
||||||
|
}
|
||||||
|
|
||||||
db, err := sql.Open("libsql", dbName)
|
db, err := sql.Open("libsql", dbPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "failed to open db %s", err)
|
fmt.Fprintf(os.Stderr, "failed to open db %s: %v", dbPath, err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue