Preferred Way to Stop the Gremlin Server

1,011 views
Skip to first unread message

Andrew Guldman

unread,
Nov 1, 2014, 1:19:23 AM11/1/14
to gremli...@googlegroups.com
I am running TinkerPop3 Gremlin Server with Neo4j. To start the Gremlin Server, I am doing:
cd tinkerpop3/gremlin-server/target/gremlin-server-3.0.0.M4-standalone
bin/gremlin-server.sh conf/gremlin-server-neo4j.yaml

To stop the server, I am pressing ^c in the shell in which I started Gremlin Server. It superficially appears to work fine. Is that the preferred way to stop Gremlin Server? Is there a script I can call to stop it? Some parameters to send to gremlin-server.sh?

Thanks for your help!
Andrew

Stephen Mallette

unread,
Nov 1, 2014, 12:29:11 PM11/1/14
to gremli...@googlegroups.com
After trying things out myself, I'm not so convinced Gremlin Server is shutting down as gracefully as I thought it was with ctrl-c.  I've created an issue:


I'll look to try to resolve this for M5 release.  For now, I don't have any other workarounds - so crtrl-c is all there is. Thanks for pointing this out.

Stephen

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/6019b39a-19e3-4a45-a5de-354c5efa6756%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Guldman

unread,
Nov 5, 2014, 8:45:17 PM11/5/14
to gremli...@googlegroups.com
Hi Stephen,

I have turned my attention from experimenting in the Mac terminal to getting Gremlin Server to run on an ec2 server that is provisioned by Chef. This is prompting me to revisit this thread...

We are currently starting Gremlin Server on an ec2 server by running the following bash script from a Chef provisioning script:

cd vendor/tinkerpop3/gremlin-server/target/gremlin-server-3.0.0.M4-standalone
bin/gremlin-server.sh conf/gremlin-server-neo4j.yaml > gremlin-server.log &

It works to start the server but it is even more awkward to stop gremlin server than pressing ^c in a shell. Now it seems like we need to use ps to find the process id, then kill to kill it. Not ideal. The urgency for a more palatable solution is increasing. Am I missing something? Any luck getting a fix to this into the M5 release?

(I don't see any updates in the github issue. Would you prefer me to comment here or in the github issue manager?)

Thanks,
Andrew

Stephen Mallette

unread,
Nov 6, 2014, 12:12:03 PM11/6/14
to gremli...@googlegroups.com
The incomparable Mr. Kuppitz came up with this upstart script for Gremlin Server:


You should be able to just add it to /etc/init which will allow:

start gremlin-server
stop gremlin-server

Does that help your situation?

Andrew Guldman

unread,
Nov 6, 2014, 3:01:15 PM11/6/14
to gremli...@googlegroups.com
Hi Stephen (and Mr. Kuppitz),

Much better. Thanks!

One thing I see is that it only works if the Gremlin user is root. If the Gremlin user is not root, I get errors like:

[WARN] Graphs - Graph [g_ci1] configured at [conf/neo4j-ci1.properties] could no
t be instantiated and will not be available in Gremlin Server.  GraphFactory mes
sage: GraphFactory could not instantiate this Graph implementation [com.tinkerpo
p.gremlin.neo4j.structure.Neo4jGraph]

When the Gremlin user is root, that graph is correctly instantiated.

Maybe that's because I installed Gremlin Server as root? Thoughts? Suggestions?

Thanks,
Andrew

Daniel Kuppitz

unread,
Nov 6, 2014, 5:13:53 PM11/6/14
to gremli...@googlegroups.com
Hi Andrew,

make sure that the GREMLIN_USER has full access to
  1. Gremlin Server of course and
  2. the Neo4j data directory
To me the error message looks like (2) is currently not the case.

Cheers,
Daniel


Andrew Guldman

unread,
Nov 21, 2014, 10:54:55 AM11/21/14
to gremli...@googlegroups.com
Hi Daniel,

Thanks for the tips. I finally made time to explore this in more detail. I made some minor changes to the script you provided so that the log and data directories are subdirectories of the "standard" /var/log and /tmp directories that are shared by other apps. (Of course, I also had to change my Gremlin Server config properties files to point to the same data directory.)

Before I made these changes, the "if [ ! -d $LOG_DIR ];" test in the startup script never succeeded because the /var/log directory already existed. Consequently, the $GREMLIN_USER was not given ownership of the log and data directories, and (as you suggested) the $GREMLIN_USER did not have full access to the data directory.

I also noticed that the $GREMLIN_DATA_DIR variable was never assigned a value in the original version of the script. That was an easy fix.

It seems like it is running smoothly now.

An updated version of the complete script we are using is pasted below, in case it is helpful to you or anybody else. You will notice that it includes some hard-coded paths for our server environment and Gremlin Server configuration. It would be great to include this script with the standard distribution of Gremlin Server. I'd imagine that I would not be the only one who would appreciate using it.

Thanks!!!
Andrew

#!upstart
description "Gremlin Server"
 
env GREMLIN_USER=gremlin-user
env GREMLIN_GROUP=gremlin-group
env GREMLIN_PID_FILE=/var/run/gremlin.pid
env GREMLIN_LOG=/var/log/gremlin/gremlin-server.log
env GREMLIN_DATA_DIR=/tmp/gremlin
 
# uncomment the next line if you want Gremlin Server to start automatically after system reboots
start on filesystem and net-device-up IFACE=eth0
stop on [016]
 
respawn
 
pre-start script
  LOG_DIR=`dirname $GREMLIN_LOG`
  if [ ! -d $LOG_DIR ]; then
    mkdir -p $GREMLIN_DATA_DIR $LOG_DIR
    chown -R $GREMLIN_USER:$GREMLIN_GROUP $GREMLIN_DATA_DIR $LOG_DIR
  fi
end script
 
script
  if [ -f /etc/default/gremlin-server ]; then . /etc/default/gremlin-server; fi
  exec start-stop-daemon --start --make-pidfile --pidfile $GREMLIN_PID_FILE --chuid $GREMLIN_USER --chdir $GREMLIN_HOME --exec $GREMLIN_HOME/bin/gremlin-server.sh $GREMLIN_HOME/conf/gremlin-server-xps-http.yaml >> $GREMLIN_LOG 2>&1
end script
 
post-stop script
  rm -f $GREMLIN_PID_FILE
end script

Daniel Kuppitz

unread,
Nov 21, 2014, 12:13:40 PM11/21/14
to gremli...@googlegroups.com
Hi Andrew,

so that the log and data directories are subdirectories of the "standard" /var/log and /tmp directories

that's already the case in my Gist.

I also noticed that the $GREMLIN_DATA_DIR variable was never assigned a value

Yea, I forgot to remove it. Actually you don't need it at all, do you? Originally I copied my Cassandra upstart script and replaced all occurrences of CASSANDRA with GREMLIN, I must have overlooked GREMLIN_DATA_DIR.

Anyway, I'm glad you figured it out and that it's working on your side now.

Cheers,
Daniel



Andrew Guldman

unread,
Nov 21, 2014, 1:27:24 PM11/21/14
to gremli...@googlegroups.com
I think that the GREMLIN_DATA_DIR references are useful in that they assign ownership of that directory to GREMLIN_USER. But you raise a good point: I'm not totally sure that it is necessary.

Thanks again for your help!

--
Andrew Guldman
Chief Architect, Fluid Inc

--
You received this message because you are subscribed to a topic in the Google Groups "Gremlin-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gremlin-users/uA48IQ3YJcw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/CAO7ueZLXbZz7N4ir-AjZT--dXc_ANSb6_uuUou8xwzQL-4T__w%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages