start() {
if status --pidfile $pidfile lxd lxd >/dev/null; then
msg_already_running "lxd"
+ RETVAL=1
return
fi
-
+
msg_starting "lxd"
- daemon --fork --waitforname lxd /usr/sbin/lxd daemon $OPTIONS
+ daemon --fork --waitforname lxd /usr/lib/lxd-wrapper daemon $OPTIONS
# lxd does not write pidfile, so create one
show "Checking lxd daemon status"
busy
- pid=""
- ntry=0
- while [ -z "$pid" -a $ntry -lt 5 ]; do
- [ -z "$pid" ] && sleep 1
- pid=$(lxc info | awk '/serverpid:/{print $2}')
- echo $pid > $pidfile
- ntry=$(($ntry+1))
- done
+
+ if lxd waitready --timeout=16 2>/dev/null; then
+ pid=$(lxc info 2>/dev/null | awk '/server_pid:/{print $2}')
+ [ -n "$pid" ] && echo $pid > $pidfile
+ fi
if [ -n "$pid" ]; then
- touch /var/lock/subsys/lxd
- ok
- RETVAL=0
+ touch /var/lock/subsys/lxd
+ ok
+ RETVAL=0
else
- fail
- RETVAL=1
+ fail
+ RETVAL=1
fi
}
# Stop daemons.
msg_stopping "lxd"
/usr/sbin/lxd shutdown
- busy
+ busy
sleep 1
if status --pidfile $pidfile lxd lxd >/dev/null; then
killproc --pidfile $pidfile lxd
else
ok
- fi
+ fi
rm -f /var/lock/subsys/lxd
}