blob: 6b97b015d33aad28334d6c60aa7141f2a2d96b7d [file] [log] [blame]
# Copyright 2021 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 "Job to start nebraska.py"
author "chromeos-core-services@google.com"
start on starting update-engine
stop on stopping update-engine
# We only run this on test images, but its a good idea to set this so we can
# change the default.
oom score -100
env NEBRASKA_CONFIG_FILE=/usr/local/nebraska/config.json
pre-start script
# If no JSON file for updating nebraska's config was provided, don't run
# nebraska. We only want to run nebraska when we intend to do so.
if [ ! -f "${NEBRASKA_CONFIG_FILE}" ]; then
logger -t "${UPSTART_JOB}" "Can't run nebraska.py without its config file."
stop
exit 0
fi
logger -t "${UPSTART_JOB}" "Running nebraska.py."
end script
exec nebraska.py
post-start script
# Wait for the port file to appear for no more than 3 seconds.
nebraska.py --poll
if [ "$?" -ne 0 ]; then
logger -t "${UPSTART_JOB}" "Failed to find pid/port files of nebraska.py."
stop
exit 0
fi
PORT="$(cat /run/nebraska/port)"
curl -X POST -d @"${NEBRASKA_CONFIG_FILE}" \
"http://localhost:${PORT}/update_config"
end script