Fook
Fook

Reputation: 5550

Initialization of 'g' and 'graph' vars on server start

Upon starting gremlin console, the g and graph objects aren't being automatically instantiated. From reading it seems that I don't have something configured correctly to allow for this during startup.

I've checked my gremlin-server.yaml file, which includes

graphs: {
  graph: conf/gremlin-server/dynamodb.properties}

I'm able to manually create the objects in the console, so it does work

gremlin> graph = TitanFactory.open('conf/gremlin-server/dynamodb.properties');
==>standardtitangraph[com.amazon.titan.diskstorage.dynamodb.DynamoDBStoreManager:[127.0.0.1]]
gremlin> mgmt = graph.openManagement();
==>com.thinkaurelius.titan.graphdb.database.management.ManagementSystem@433b546f
gremlin> g = graph.traversal(standard());
==>graphtraversalsource[standardtitangraph[com.amazon.titan.diskstorage.dynamodb.DynamoDBStoreManager:[127.0.0.1]], standard]

Is there something else I'm missing? I found this issue logged on the gremlin-javascript project, but am still stuck. I think my problem is with my configuration on the server and not my implementation of gremlin-javascript.

Ultimately I'm trying to traverse using gremlin-javascript, but I'm forced to create 'graph' and 'g' each time (slow).

Upvotes: 1

Views: 176

Answers (1)

jbmusso
jbmusso

Reputation: 3456

This is the expected behavior when starting the Gremlin console, unless you start it with an init script that does this for you:

// scripts/initMyGraph.groovy

graph = TitanFactory.open('conf/gremlin-server/dynamodb.properties')
g = graph.traversal(standard())

Then start the console with:

bin/gremlin.sh scripts/initMyGraph.groovy

Graph and Traversal objects will be accessible as graph and g variables in the console, respectively.

Upvotes: 2

Related Questions