Skip to content

Instantly share code, notes, and snippets.

@sarmbruster
Created August 20, 2013 10:14
Show Gist options
  • Save sarmbruster/6279711 to your computer and use it in GitHub Desktop.
Save sarmbruster/6279711 to your computer and use it in GitHub Desktop.
/*
small groovy script to demo how to spawn a neo4j ha instance from own code *and* run a server on top of it
requirement for this script:
* a 3 member cluster is assumed, so either use this script 3 times with adopted config or run 2 Neo4j servers + this script
* have two files neo4j-server.properties and neo4.properties in the same directory with this script, having the following contents:
neo4j-server.properties:
========================
org.neo4j.server.database.location=/tmp/dummy
org.neo4j.server.webserver.port=7476
org.neo4j.server.webserver.https.enabled=false
org.neo4j.server.webadmin.rrdb.location=data/rrd
org.neo4j.server.webadmin.data.uri=/db/data/
org.neo4j.server.webadmin.management.uri=/db/manage/
org.neo4j.server.db.tuning.properties=neo4j.properties
org.neo4j.server.manage.console_engines=gremlin, shell
org.neo4j.server.database.mode=HA
org.neo4j.server.http.log.enabled=false
org.neo4j.server.http.log.config=conf/neo4j-http-logging.xml
neo4j.properties:
=================
keep_logical_logs=true
ha.server_id=3
ha.initial_hosts=:5000,:5001,:5002
ha.server = :6003
ha.cluster_server=:5002
*/
@Grab(group='org.neo4j.app', module='neo4j-server-enterprise', version="1.9.2")
@Grab(group='org.neo4j.app', module='neo4j-server', version="1.9.2")
@Grab(group='org.neo4j.app', module='neo4j-server', version="1.9.2", classifier="static-web")
@Grab(group='com.sun.jersey', module='jersey-core', version='1.9')
@GrabExclude(group='org.neo4j', module='neo4j') // otherwise we get a zip exception, theory: groovy grapes fail on pom dependency
import static org.neo4j.server.configuration.Configurator.*
import org.neo4j.server.enterprise.EnterpriseBootstrapper
System.setProperty( NEO_SERVER_CONFIG_FILE_KEY, "./neo4j-server.properties")
def bootStrapper = new EnterpriseBootstrapper()
bootStrapper.start()
def graphDb = bootStrapper.server.database.graph // instance of graphdatabaseservice
sleep 100000
bootStrapper.stop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment