Skip to content

Instantly share code, notes, and snippets.

@malev
Created July 5, 2016 21:08
Show Gist options
  • Save malev/02ea99a38c7a2d0551744f72f78b45ae to your computer and use it in GitHub Desktop.
Save malev/02ea99a38c7a2d0551744f72f78b45ae to your computer and use it in GitHub Desktop.
CoreNLP init file for Ubuntu 14.04
#!/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"
PORT=9000
do_start()
{
if [ -e '/tmp/corenlp.shutdown' ]; then
echo "CoreNLP server is already running!"
echo "If you are sure this is a mistake, delete the file:"
echo "/tmp/corenlp.shutdown"
else
export CLASSPATH=""
for JAR in `find /opt/corenlp -name "*.jar"`; do
CLASSPATH="$CLASSPATH:$JAR"
done
# nohup su "$SERVER_USER" -c "/usr/local/bin/authbind --deep java -Djava.net.preferIPv4Stack=true -cp "$CLASSPATH" -mx7g edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 80" &
nohup su "$SERVER_USER" -c "/usr/bin/authbind --deep java -Djava.net.preferIPv4Stack=true -cp \"/opt/corenlp/*\" -mx7g edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port $PORT" &
echo "CoreNLP server started."
fi
}
do_stop()
{
if [ ! -e '/tmp/corenlp.shutdown' ]; then
echo "CoreNLP server is not running"
else
KEY=`cat /tmp/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