How to stop/start Neo4j server via .bat script in windows

故事扮演 提交于 2020-01-03 01:51:26

问题


When running the neo4j server in Linux, we have several commands - start, stop, restart, etc - to control it via the command line.

In windows, the manual simply says:

Usage - Windows Neo4j.bat

Double-clicking on the Neo4j.bat script will start the server in a console. To quit, just press control-C in the console window.

But how do I stop it if I've started it by executing neo4j.bat from a .bat file of my own, and thus don't have a console window?

For context: I'm working on an unmanaged extension, so I need to rebuild my jar, move it into the plugins directory and restart the server each time I make a change. It'd be a pain in the ass to do this manually, so (when when I was working in Linux) I had Intellij rebuild the artifact and execute a .sh script that moved the resultant jar into /plugins and restarted neo4j.

'/path/to/neo4j/bin/neo4j' stop
rm /path/to/neo4j/plugins/api.jar
mv /project/path/artifacts/graphapi.jar /path/to/neo4j/plugins/api.jar 
'/path/to/neo4j' start

How do I do the same in windows using a .bat file?

I've tried this:

del "C:/path/to/neo/plugins/api.jar
move "C:/project/path/artifacts/api.jar" "C:/path/to/neo/plugins/api.jar"
C:/neo/bin/Neo4j.bat 

hoping that simply calling Neo4j.bat again would stop the current process and start another, but apparently that's not the case.


回答1:


If you're on Windows you can stop Neo4j server by executing: neo4j.bat stop

Let me show it in details for those who might be new to the command line:

  1. We need to know where Neo4j is located. If you remember where did you extract it - good, you can skip this step. For others: open Task Manager and look for Commons Daemon Service Runner here how it looks like right mouse click, open Properties and look for its Location path. Find this path in your file manager. We are looking for bin folder with neo4j.bat file.

  2. Open command line and write cd and then paste your path, hit enter. You should jump to that folder with neo4j.bat file.

  3. Stop the server: Type neo4j.bat stop and execute. It will ask for your permission .

after that, you can double check and type 'neo4j.bat status` t be sure it's stopped.

P.S. After Windows reboot neo4j server will be automatically restarted. If you don't want this (it consumes up to 500Mb of memory, at least in my DB ~64k records) you should uninstall the service. Execute neo4j.bat uninstall-service in that directory.

Cheers!



来源:https://stackoverflow.com/questions/31841109/how-to-stop-start-neo4j-server-via-bat-script-in-windows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!