blob: 4699f4d8d8617bb765209efa8753559e4004fed3 [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
respawn limit 3 10
script
. /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
LOG=/var/log/servod.log
# Number of old logs we keep is selected so that if we die from
# the respawn limit, we'll have logs from all failed respawns,
# plus one more.
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 servod --host 0.0.0.0 $BOARD_FLAG >$LOG 2>&1
end script