Database Reference
In-Depth Information
Let's look at these steps in turn.
Shut down the neo4j instance
If you're running in a single server mode, you simply need to execute the neo4j script
witha stop argument.AssumingNeo4jwasinstalledin/opt/neo4j/bin,youcouldstopthe
server by issuing this command:
/opt/neo4j/bin/neo4j stop
If you have embedded Neo4j in your application, then unless you've explicitly provided
a mechanism to only shut down the Neo4j database, you should stop your application
with whatever mechanism you have chosen to use. This could be as simple as sending a
SIGINT signal (for example, issuing Ctrl-C in a terminal window if your application has
been launched in this manner), or it may be more elaborate, involving a special script or
custom application functionality.
Whatever the mechanism, you should ensure that Neo4j is also shut down when this pro-
cess occurs. You saw in listing 10.3 in the previous chapter what was required to ensure
thisoccurredwhenrunninginembeddedmode.Torefreshyourmemory,here'sthesnippet
of code that registers a shutdown hook:
private String DB_PATH = '/var/data/neo4jdb-private';
private GraphDatabaseService graphdb =
new GraphDatabaseFactory().newEmbeddedDatabase( DB_PATH );
registerShutdownHook( graphDb );
...
private static void registerShutdownHook(
final GraphDatabaseService graphDb )
{
Runtime.getRuntime().addShutdownHook( new Thread()
{
@Override
public void run()
{
graphDb.shutdown();
}
} );
}
Search WWH ::




Custom Search