-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add startup script; allow gracefull shutdown of server
- Loading branch information
Gabor Angeli
authored and
Stanford NLP
committed
Sep 19, 2015
1 parent
4cb7bc4
commit b477bd9
Showing
2 changed files
with
113 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/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" | ||
|
||
do_start() | ||
{ | ||
if [ -e '/tmp/corenlp.shutdown' ]; then | ||
echo "CoreNLP server is alredy 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 80" & | ||
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 | ||
} | ||
|
||
case $1 in | ||
start) do_start | ||
;; | ||
stop) do_stop | ||
;; | ||
esac | ||
|