Neo4j Shutdown hook

65 views
Skip to first unread message

KCD

unread,
Apr 19, 2012, 8:35:19 AM4/19/12
to Neo4j
I am installing Neo4j on amazon cloud with chef. The server starts
fine but as soon as the chef process is complete the server shuts
down. Looks like the shut down hook is invoked.

4/19/12 11:46:14 AM org.neo4j.server.NeoServerWithEmbeddedWebServer
INFO: Server
started on [http://localhost:7474/]
4/19/12 11:47:00 AM org.neo4j.server.NeoServerBootstrapper INFO: Neo4j
Server sh
utdown initiated by kill signal
4/19/12 11:47:00 AM
org.neo4j.server.statistic.StatisticStartupListener INFO: st
opping filter


Is there a way to disable the shut down hook via config?

Thanks,
KCD

Julian Simpson

unread,
Apr 19, 2012, 9:55:06 AM4/19/12
to ne...@googlegroups.com
Hi,

Any more detail on how you invoke Neo4j?  It's shutting down because of a kill signal (presumably because a shell invoked by Chef is finishing).

Julian.


 

Thanks,
KCD

KCD

unread,
Apr 19, 2012, 10:32:27 AM4/19/12
to Neo4j
This is the recipe I used:


#
# Cookbook Name:: neo4j-server
# Recipe:: tarball
# Copyright 2012, Michael S. Klishin <michael...@me.com>
#
# Permission is hereby granted, free of charge, to any person
obtaining a copy
# of this software and associated documentation files (the
"Software"), to deal
# in the Software without restriction, including without limitation
the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell
# copies of the Software, and to permit persons to whom the Software
is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN
# THE SOFTWARE.

include_recipe "java"

#
# User accounts
#

user node.neo4j.server.user do
comment "Neo4J Server user"
home node.neo4j.server.installation_dir
shell "/bin/bash"
action :create
end

group node.neo4j.server.user do
(m = []) << node.neo4j.server.user
members m
action :create
end

# 1. Download the tarball to /tmp
require "tmpdir"

td = Dir.tmpdir
tmp = File.join(td, "neo4j-community-
#{node.neo4j.server.version}.tar.gz")
tarball_dir = File.join(td, "neo4j-community-
#{node.neo4j.server.version}")

remote_file(tmp) do
source node.neo4j.server.tarball.url

not_if "which neo4j"
end

# 2. Extract it
# 3. Copy to /usr/local/neo4j-server, update permissions
bash "extract #{tmp}, move it to
#{node.neo4j.server.installation_dir}" do
user "root"
cwd "/tmp"

code <<-EOS
rm -rf #{node.neo4j.server.installation_dir}
tar xfz #{tmp}
mv --force #{tarball_dir} #{node.neo4j.server.installation_dir}
EOS

creates "#{node.neo4j.server.installation_dir}/bin/neo4j"
end

[node.neo4j.server.conf_dir, node.neo4j.server.data_dir,
File.join(node.neo4j.server.data_dir, "log")].each do |dir|
directory dir do
owner node.neo4j.server.user
group node.neo4j.server.user
recursive true
action :create
end
end

[node.neo4j.server.lib_dir, node.neo4j.server.data_dir,
File.join(node.neo4j.server.installation_dir, "data")].each do |dir|
# Chef sets permissions only to leaf nodes
bash "chown -R #{node.neo4j.server.user}:#{node.neo4j.server.user}
#{dir}" do
user "root"

code "chown -R #{node.neo4j.server.user}:#{node.neo4j.server.user}
#{dir}"
end
end

# 4. Symlink
%w(neo4j neo4j-shell).each do |f|
link "/usr/local/bin/#{f}" do
owner node.neo4j.server.user
group node.neo4j.server.user
to "#{node.neo4j.server.installation_dir}/bin/#{f}"
end
end

# 5. Install config files
template "#{node.neo4j.server.conf_dir}/neo4j-server.properties" do
source "neo4j-server.properties.erb"
owner node.neo4j.server.user
mode 0644
end

template "#{node.neo4j.server.conf_dir}/neo4j-wrapper.conf" do
source "neo4j-wrapper.conf.erb"
owner node.neo4j.server.user
mode 0644
end

# 6. Add initd service
bash "Update limits.conf for #{node.neo4j.server.user}" do
user 'root'

code <<-END.gsub(/^ /, '')
echo '#{node.neo4j.server.user} - nofile
#{node.neo4j.server.limits.nofile}' >> /etc/security/limits.conf
echo '#{node.neo4j.server.user} - memlock
#{node.neo4j.server.limits.memlock}' >> /etc/security/limits.conf
echo 'session required
pam_limits.so' >> /etc/pam.d/su
END
end

template "/etc/init.d/neo4j" do
source "neo4j.init.erb"
owner 'root'
mode 0755
end

service "neo4j" do
supports :start => true, :stop => true, :status => true, :restart =>
true
action [:enable, :start]
end



On Apr 19, 9:55 am, Julian Simpson <julian.simp...@neotechnology.com>
wrote:

Julian Simpson

unread,
Apr 20, 2012, 4:50:00 AM4/20/12
to ne...@googlegroups.com

Hi,

On Thursday, April 19, 2012, KCD wrote:
This is the recipe I used:


Not sure how Chef is invoking the service, but it breaks expectations that the service should quit.  Oddly, I haven't seen this in puppet.  Is it possible to try executing the init script directly from Chef?

Julian.

KCD

unread,
Apr 20, 2012, 10:11:03 AM4/20/12
to Neo4j
I have tried running the /etc/init.d/neo4j service directly too. The
result is same.
Is there a way to run4j as a daemon service?

On Apr 20, 4:50 am, Julian Simpson <julian.simp...@neotechnology.com>
wrote:
> Hi,
>
> On Thursday, April 19, 2012, KCD wrote:
> > This is the recipe I used:
>
> Not sure how Chef is invoking the service, but it breaks expectations that
> the service should quit.  Oddly, I haven't seen this in puppet.  Is it
> possible to try executing the init script directly from Chef?
>
> Julian.
>
>
>
>
>
>
>
>
>
> > #
> > # Cookbook Name:: neo4j-server
> > # Recipe:: tarball
> > # Copyright 2012, Michael S. Klishin <michaelklis...@me.com>

Julian Simpson

unread,
Apr 20, 2012, 10:23:07 AM4/20/12
to ne...@googlegroups.com
Hi,

On Fri, Apr 20, 2012 at 3:11 PM, KCD <kaml...@gmail.com> wrote:
I have tried running the /etc/init.d/neo4j service directly too. The
result is same.
Is there a way to run4j as a daemon service?


Yes.  The Debian packages are a good example of this working.  Do you mind contacting me off-list, and we can discuss some gory detail?

Best

Julian.
Reply all
Reply to author
Forward
0 new messages