Changes to get cayley running on appengine again.

This commit is contained in:
= 2014-11-28 13:36:12 +01:00 committed by panamafrancis
parent 5e61e2ecad
commit fbb3fc87ba
2 changed files with 81 additions and 11 deletions

View file

@ -18,20 +18,90 @@ package main
import ( import (
"github.com/barakmich/glog" "github.com/barakmich/glog"
"os"
"time"
"github.com/google/cayley/config" "github.com/google/cayley/config"
"github.com/google/cayley/db" "github.com/google/cayley/db"
"github.com/google/cayley/graph" "github.com/google/cayley/graph"
"github.com/google/cayley/http" "github.com/google/cayley/http"
_ "github.com/google/cayley/graph/memstore" _ "github.com/google/cayley/graph/gaedatastore"
_ "github.com/google/cayley/writer"
) )
var (
quadFile = ""
quadType = "cquad"
cpuprofile = ""
queryLanguage = "gremlin"
configFile = ""
databasePath = ""
databaseBackend = "gaedatastore"
replicationBackend = "single"
host = "127.0.0.1"
loadSize = 100
port = "64210"
readOnly = false
timeout = 30 * time.Second
)
func configFrom(file string) *config.Config {
// Find the file...
if file != "" {
if _, err := os.Stat(file); os.IsNotExist(err) {
glog.Fatalln("Cannot find specified configuration file", file, ", aborting.")
}
} else if _, err := os.Stat("/cayley_appengine.cfg"); err == nil {
file = "/cayley_appengine.cfg"
}
if file == "" {
glog.Infoln("Couldn't find a config file appengine.cfg. Going by flag defaults only.")
}
cfg, err := config.Load(file)
if err != nil {
glog.Fatalln(err)
}
if cfg.DatabasePath == "" {
cfg.DatabasePath = databasePath
}
if cfg.DatabaseType == "" {
cfg.DatabaseType = databaseBackend
}
if cfg.ReplicationType == "" {
cfg.ReplicationType = replicationBackend
}
if cfg.ListenHost == "" {
cfg.ListenHost = host
}
if cfg.ListenPort == "" {
cfg.ListenPort = port
}
if cfg.Timeout == 0 {
cfg.Timeout = timeout
}
if cfg.LoadSize == 0 {
cfg.LoadSize = loadSize
}
cfg.ReadOnly = cfg.ReadOnly || readOnly
return cfg
}
func init() { func init() {
glog.SetToStderr(true) glog.SetToStderr(true)
cfg, _ := config.Load("cayley_appengine.cfg") cfg := configFrom("cayley_appengine.cfg")
qs, _ := graph.NewQuadStore("memstore", "", nil) handle, err := db.Open(cfg)
glog.Errorln(cfg) if err != nil {
db.Load(qs, cfg, cfg.DatabasePath) glog.Fatal(err)
http.SetupRoutes(qs, cfg) }
http.SetupRoutes(&handle, cfg)
} }

View file

@ -1,7 +1,7 @@
{ {
"database": "mem", "database": "gaedatastore",
"db_path": "30kmoviedata.nq.gz", "read_only": false,
"read_only": true, "load_size": 100,
"load_size": 10000, "timeout": 10,
"timeout": 10 "http_request_context":true
} }