Neo4j write support for rails console and IRB console #99

dnagir opened this Issue Dec 14, 2011 · 6 comments


None yet

3 participants

dnagir commented Dec 14, 2011

Since only one process can access the database in write mode we must have some kind of socket connection from IRB to the server instead.

There is no need to replicate the embedded API to the socket client. We could maybe start the irb from the server and capture the stdin and stdout out.
Or just eval the input we get and set the output over the socket.

dnagir commented Dec 14, 2011

Dmytrii Nagirniak

December 7th, 2011 @ 10:29 PM
Maybe we can just start an IRB/Pry session in the new thread somehow?
I am not sure that stdin/out redirects would work well taking into account all the different terminals, encoding and even color codes etc.

Andreas Ronge

December 7th, 2011 @ 10:53 PM
Yes, maybe something like that, start with plain socket and a thread.
And then we can telnet to the application, as a first step.
It would also be nice to allow all kind of different terminals.
My favorite protocol is XMPP which would enable talking to the rails server using a standard chat client.

Andreas Ronge

December 7th, 2011 @ 10:59 PM
Maybe this could be useful:

iRonin commented Mar 16, 2012

If I get your problem right (trying to access neo4j from multiple clients - say, rails app and its console), one potential resolution is using Neo4J in HA Cluster mode.
So far I've got up to the following point:

11:59:06,985 INFO  [org.apache.zookeeper.ClientCnxn](http-- Session establishment complete on server localhost/, sessionid = 0x1361b20a8df0002, negotiated timeout = 6000
java.lang.RuntimeException: There's already an HA cluster managed by this ZooKeeper cluster

iRonin commented Mar 16, 2012

Here is my temporary solution for simultaneous write access to Neo4j HA cluster from two clients - I tested it with two instances of rails console.

  1. Start ZooKeeper from ha-cluster example (,
  2. Start rails console,
  3. Manipulate config.neo4j in application.rb to get new rails console to start a new instance of neo4j that uses different storage dir and works as a slave:
config.neo4j['storage_path'] = 'db/serv_1'
config.neo4j['ha.db'] = true
config.neo4j['ha.server_id'] = 1
config.neo4j['ha.server'] = 'localhost:6001'

I reckon this could be parametrized and quite easy to use, though would be nice to, say, get the new instance of the app to recognize if this should be done automatically, or something. This could be achieved by checking for the lock file in, say, "db/neo4j-development-#{neo4j_server_id}". Slave storage dirs could be cleaned up on exit for dev env.


Great. Maybe this is the easiest solution for this issue. There is code for checking the the database is locked in the Neo4j::Database. Yes, a little script for starting and configure this would be nice.

@andreasronge andreasronge added a commit that referenced this issue Jun 9, 2012
@andreasronge andreasronge Added support to access the rails console with write access at the sa…
…me time as the rails application is running #99

Looks like it works !
You need to include the neo4j-enterprise and neo4j-advanced gem as development deps (see license)
Then you include the ha_console railitie in your application.rb.
This is all that is needed to get the rails console working using a Neo4j HA cluster.
@andreasronge andreasronge added a commit that referenced this issue Dec 28, 2012
@andreasronge andreasronge Support for HA cluster with neo4j, 1.9.X, #228, #99, #223
* Fixed for IRB/Pry console using HA to concurrently access the database
* Updated the HA examples
* Removed ZooKeeper and its configuration

Zookeeper is gone since we use Neo4j 1.9.M03 :)

Use Rails console with ha enabled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment