blob: a0f16c1c29cfd447a192adb49ae662ed814dd84e [file] [log] [blame]
# Copyright 2020 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
description "Start Chrome OS iio service"
author "chromium-os-dev@chromium.org"
# Start when mems_setup has set proper group and ownership.
start on started mojo_service_manager
stop on stopping mojo_service_manager
expect fork
respawn
respawn limit 10 22
# Don't respawn too aggressively so that the respawn limitation is not
# exceeded during the tests (in CQ mostly).
env RESPAWN_DELAY=2
# Make iioservice killable, because if it has a leak it's better to
# restart it than to OOM-panic.
oom score -100
# Let the daemon crash if it grows too much. "as" is "address space" (vm
# size). We expect a typical VM size of about 200MB for the daemon.
limit as 200000000 unlimited
post-stop script
# If post-stop is somehow killed for timeout, treat that as a clean exit.
trap "exit 0" TERM
goal=$(status iioservice | awk '{split($2, a, "/"); print a[1]}')
if [ "${goal}" = "start" ]; then
# Sleep only if it's respawning, so we don't need to wait when doing `stop
# iioservice` in tests or manually.
sleep "${RESPAWN_DELAY}"
fi
end script
exec minijail0 --config /usr/share/minijail/iioservice.conf \
-- /usr/sbin/iioservice