separate master and worker

This commit is contained in:
ooooo 2016-04-20 14:50:53 +08:00
parent 56242920c4
commit 839ea23135
2 changed files with 15 additions and 6 deletions

View File

@ -44,7 +44,6 @@ PIDFILE=$RUN_DIR/$DAEMON_NAME.pid
###########
pre_start () {
[ ! -d $FS_PREFIX/global ] && mkdir -p $FS_PREFIX/global
[ ! -d $FS_PREFIX/local ] && mkdir -p $FS_PREFIX/local
[ ! -d $FS_PREFIX/global/users ] && mkdir -p $FS_PREFIX/global/users
@ -86,18 +85,25 @@ do_start() {
log_end_msg $?
}
do_changestage () {
RUNNING_CONFIG=$FS_PREFIX/local/docklet-running.conf
export CONFIG=$RUNNING_CONFIG
log_daemon_msg "Change $DAEMON_NAME daemon state"
cmd=$(python3 ../src/stopworker.py)
log_end_msg $?
}
do_stop () {
log_daemon_msg "Stopping $DAEMON_NAME daemon"
start-stop-daemon --stop --quiet --oknodo --remove-pidfile --pidfile $PIDFILE --retry 10
log_end_msg $?
log_daemon_msg "Change $DAEMON_NAME daemon state"
pre_start
start-stop-daemon --start --oknodo --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --startas $STOP_DAEMON -- $DAEMON_OPTS
log_end_msg $?
do_changestage
}
case "$1" in
start)
do_start
@ -121,6 +127,9 @@ case "$1" in
status_of_proc -p $PIDFILE "$DAEMON" "$DAEMON_NAME" && exit 0 || exit $?
;;
change)
do_changestage
;;
*)
echo "Usage: $DAEMON_NAME {start|stop|restart|status}"
exit 1

View File

@ -10,4 +10,4 @@ if __name__ == '__main__':
etcdclient = etcdlib.Client(etcdaddr, prefix = clustername)
net_dev = env.getenv("NETWORK_DEVICE")
ipaddr = network.getip(net_dev)
etcdclient.setkey("machines/runnodes/"+ipaddr, "stop")
etcdclient.deldir("machines/runnodes/"+ipaddr)