mirror of
https://github.com/Threnklyn/zeit.git
synced 2026-05-18 21:03:30 +02:00
Made database file configurable through ZEIT_DB
This commit is contained in:
+7
-1
@@ -1,6 +1,7 @@
|
||||
package z
|
||||
|
||||
import (
|
||||
"os"
|
||||
"log"
|
||||
"errors"
|
||||
"strings"
|
||||
@@ -14,7 +15,12 @@ type Database struct {
|
||||
}
|
||||
|
||||
func InitDatabase() (*Database, error) {
|
||||
db, err := buntdb.Open(":memory:") // TODO: Replace with file
|
||||
dbfile, ok := os.LookupEnv("ZEIT_DB")
|
||||
if ok == false || dbfile == "" {
|
||||
return nil, errors.New("please `export ZEIT_DB` to the location the zeit database should be stored at")
|
||||
}
|
||||
|
||||
db, err := buntdb.Open(dbfile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user