blob: 57276053572c688b91d2818a48dffb2a1e939894 [file] [log] [blame]
# Copyright 2018 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 "Chrome OS Machine Learning service"
author "chromium-os-dev@chromium.org"
# This daemon is started by D-Bus service activation configured in
# ml/dbus/org.chromium.MachineLearning.service.
stop on stopping system-services
expect fork
pre-start script
logger -t "${UPSTART_JOB}" "Pre-start ml-service"
mkdir -m 0755 -p /var/lib/ml_service/metrics
chown -R ml-service:ml-service /var/lib/ml_service
# Check if system-services is still running before starting ml-service.
# This is to prevent new dbus-activated instances from getting started once
# the system is beginning to shut down.
if ! initctl status system-services | grep -q running; then
logger -t "${UPSTART_JOB}" "ERROR: system services not running, quit."
stop
exit 0
fi
end script
# --profile=minimalistic-mountns Mount namespace with basic mounts
# includes /var/empty, /, /proc (RO), /dev/log, /tmp (tmpfs)
# -b /var/lib/ml_service for ml_service metrics
# -b /var/lib/metrics for uma metrics
# -k /run/imageloader with MS_BIND|MS_REC to pick up any new DLC package mounts
exec minijail0 -e -i -n -p -l --uts -v -Kslave -c 0 \
--profile=minimalistic-mountns \
-k tmpfs,/var,tmpfs \
-k tmpfs,/run,tmpfs \
-k '/run/imageloader,/run/imageloader,none,MS_BIND|MS_REC' \
-b /run/dbus \
-b /var/lib/ml_service,,1 \
-b /var/lib/metrics,,1 \
-S /usr/share/policy/ml_service-seccomp.policy \
-u ml-service -g ml-service -- /usr/bin/ml_service
post-start script
logger -t "${UPSTART_JOB}" "Post-start ml-service"
# Wait for daemon to claim its D-Bus name before transitioning to started.
exec minijail0 -u ml-service -g ml-service /usr/bin/gdbus \
wait --system --timeout 15 org.chromium.MachineLearning
end script
post-stop exec logger -t "${UPSTART_JOB}" "Post-stop ml-service"