blob: 38233d1c4d17ab5b12bc73daca2c9ffb5343b4ba [file] [log] [blame]
# Copyright 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
description "Start servod"
author "chromium-os-dev@chromium.org"
start on net-device-up
stop on runlevel [!2345]
respawn
# If you change the respawn limit, change the log rotation, below.
respawn limit 3 10
script
LOG=/var/log/servod.log
# We set OLD to ".4" to correspond to the respawn limit of 3
# above. That way, if we die from the respawn limit, we'll have
# logs from all failed respawns, plus the original log that
# presumably contains the first failure.
OLD=.4
for NEW in .3 .2 .1 ''; do
if [ -f $LOG$NEW ]; then
mv -f $LOG$NEW $LOG$OLD
fi
OLD=$NEW
done
exec >$LOG 2>&1
. /etc/default/servod
if [ -n "$BOARD" ]; then
BOARD_FLAG="--board ${BOARD}"
logger -t "$UPSTART_JOB" "Launching servod for ${BOARD}"
else
BOARD_FLAG=""
logger -t "$UPSTART_JOB" "Launching servod with unspecified DUT board"
fi
echo "================= Version information ================="
echo "$REVISION"
echo "======================================================="
exec servod --debug --host 0.0.0.0 $BOARD_FLAG
end script