Last active
May 16, 2017 13:22
-
-
Save zduymz/40abddee43b7244dff0deeb39319e966 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# A script to start/stop the CoreNLP server on port 80, made | |
# in particular for the configuration running at corenlp.run. | |
# This script should be placed into: | |
# | |
# /etc/init.d/corenlp | |
# | |
# To run it at startup, link to the script using: | |
# | |
# ln -s /etc/init.d/conenlp /etc/rc.2/S75corenlp | |
# | |
# Usage: | |
# | |
# service corenlp [start|stop] | |
# ./corenlp [start|stop] | |
# | |
# | |
# Set this to the username you would like to use to run the server. | |
# Make sure that this user can authbind to port 80! | |
# | |
SERVER_USER="nlp" | |
CORENLP_DIR="/opt/corenlp" | |
do_start() | |
{ | |
if [ -e "$CORENLP_DIR/corenlp.shutdown" ]; then | |
echo "CoreNLP server is already running!" | |
echo "If you are sure this is a mistake, delete the file:" | |
echo "$CORENLP_DIR/corenlp.shutdown" | |
else | |
export CLASSPATH="" | |
for JAR in `find "$CORENLP_DIR" -name "*.jar"`; do | |
CLASSPATH="$CLASSPATH:$JAR" | |
done | |
nohup su "$SERVER_USER" -c "/usr/bin/authbind --deep java -Djava.net.preferIPv4Stack=true -Xms2048m -Xmx4096m -XX:MaxNewSize=1024m -Djava.io.tmpdir="$CORENLP_DIR" -cp "$CLASSPATH" -mx15g edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 8080 -timeout 650000 " \ | |
> "$CORENLP_DIR/stdout.log" 2> "$CORENLP_DIR/stderr.log" & | |
echo "CoreNLP server started." | |
fi | |
} | |
do_stop() | |
{ | |
if [ ! -e "$CORENLP_DIR/corenlp.shutdown" ]; then | |
echo "CoreNLP server is not running" | |
else | |
KEY=`cat "$CORENLP_DIR/corenlp.shutdown"` | |
curl "localhost/shutdown?key=$KEY" | |
echo "CoreNLP server stopped" | |
fi | |
} | |
do_restart() | |
{ | |
do_stop | |
sleep 3 | |
do_start | |
} | |
case $1 in | |
start) do_start | |
;; | |
stop) do_stop | |
;; | |
restart) do_restart | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment