sentinel_file = '/etc/chef_bootstrap_complete'

service 'neo4j' do
  supports 'restart' => true, 'status' => true, 'reload' => false
  action [:enable, :start]
  only_if { node['neo4j']['service']['enabled'] }
end

ruby_block 'restart_neo4j' do
  block do
    FileUtils.touch(sentinel_file) if node.environment == 'prod'
    resources('service[neo4j]').run_action(:restart)
  end
  action :nothing
  only_if do
    if node.environment == 'prod'
      !File.exist?(sentinel_file)
    else
      node['neo4j']['config']['restart_on_change']
    end
  end
end
