Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start Neo4j on app startup #238

Closed
wants to merge 2 commits into from
Closed

Conversation

dwbutler
Copy link

As discussed in #237, Neo4j startup seems to not be thread safe. Until we can figure out the root cause, this patch simply starts up Neo4j on app startup if config.threadsafe! is enabled. This works for me and resolves the issues I was having.

@dwbutler
Copy link
Author

After using this for a little while, I realized that this causes Neo4j to always start up when the Rails environment is loaded, for example when loading the console or running a Rake task. Ideally, it would only start up when launching the Rails server. Not sure what's the best strategy here.

@dwbutler
Copy link
Author

I didn't realize allow_concurrency was deprecated. On further reflection, I think this is the wrong approach anyway. One may want Neo4j to start automatically on app start up for other reasons, unrelated to thread safety.

As discussed in #237, I think we should try to fix the root problem and make Neo4j start up thread safe, and additionally make auto start up configurable. I'll refactor this pull request to add the configuration option.

@andreasronge
Copy link
Member

Great thanks !

@dwbutler
Copy link
Author

I modified this pull request to use config.neo4j.auto_start.

I would consider this setting to be a workaround until we figure out how to make Neo4j.start threadsafe. Using this setting inherently makes it threadsafe because the server won't accept any requests (and hence won't launch any threads) until the whole app has initialized.

@andreasronge
Copy link
Member

Looks like this is solved in neo4jrb/neo4j-core#23

@dwbutler
Copy link
Author

Hi @andreasronge,

I upgraded to the latest Neo4j (with thread safe start) and turned off auto start. However, I found this to be less than ideal because the first request to the app has to wait for Neo4j to start. This can take many seconds. Ideally the app won't accept any requests until Neo4j is already started up.

I think auto start should be included as a part of Neo4j. Personally, I prefer Neo4j to auto-start in all environments except development. I'd like to submit a new pull request with improved implementation if you think this is a good feature to include.

@andreasronge
Copy link
Member

Yes I think so - there should be a default rails configuration (railtie)
that will start the neo4j by default if in production mode.

On Fri, May 24, 2013 at 10:01 PM, David Butler notifications@github.comwrote:

Hi @andreasronge https://github.com/andreasronge,

I upgraded to the latest Neo4j (with thread safe start) and turned off
auto start. However, I found this to be less than ideal because the first
request to the app has to wait for Neo4j to start. This can take many
seconds. Ideally the app won't accept any requests until Neo4j is already
started up.

I think auto start should be included as a part of Neo4j. Personally, I
prefer Neo4j to auto-start in all environments except development. I'd like
to submit a new pull request with improved implementation if you think this
is a good feature to include.


Reply to this email directly or view it on GitHubhttps://github.com//pull/238#issuecomment-18426737
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants