-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathnewsblaster.sh
executable file
·77 lines (64 loc) · 1.99 KB
/
newsblaster.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
# Run-level Startup script for the NewsBlaster
#
# description: Startup/Shutdown Oracle listener and instance
# if NB_HOME not set -- display error
if [ -z "$NB_HOME" ]; then
NB_HOME="$HOME/newsblaster_home"
mkdir -p "$NB_HOME"
export NB_HOME
echo "Setting NB_HOME to $NB_HOME"
else
echo "Override default NB_HOME with user variable $NB_HOME"
#Set to users
NB_HOME=$NB_HOME
fi
# Ensure that NB_HOME was set correctly
if [ ! -f $NB_HOME/bin/mongo -o ! -d $NB_HOME ]
then
echo "NewsBlaster: cannot start. Please check your NB_HOME path"
exit 1
fi
source $NB_HOME/venv/bin/activate
export PATH=$NB_HOME/bin:$PATH
export LD_LIBRARY_PATH=$NB_HOME/lib
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
DATA_DIR="$NB_HOME/data/db"
cd $DIR/nest
# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display
case "$1" in
start)
echo -n "Starting NewsBlaster: "
#Mongodb
$NB_HOME/bin/mongod --dbpath $DATA_DIR --fork --logpath "$DATA_DIR/mongodb.log" --bind_ip '127.0.0.1'
#Scrapyd
scrapyd > /dev/null &
#Celery
cd $DIR
celery worker --app scheduler -l info -E -B -q --concurrency 1 &> "$DATA_DIR/celery.log" &
sleep 5
echo -ne '\n'
echo "OK"
;;
stop)
echo -n "Shutdown NewsBlaster: "
scrapy_pid=`ps aux | grep scrapyd | awk '{print $2}' `
#echo "Stop scrapyd manually by running: sudo kill -9 $scrapy_pid. Process requires root "
kill -9 $scrapy_pid
celery_pid=`ps aux | grep 'celery worker' | awk '{print $2}'`
kill -9 $celery_pid
$NB_HOME/bin/mongo --eval "db.getSiblingDB('admin').shutdownServer()"
sleep 5
echo "OK"
;;
reload|restart)
bash $DIR/newsblaster.sh stop
sleep 10
bash $DIR/newsblaster.sh start
;;
*)
echo "Usage: $0 start|stop|restart|reload"
exit 1
esac
exit 0