1*5a923131SAndroid Build Coastguard Worker# 2*5a923131SAndroid Build Coastguard Worker# Copyright (C) 2012 The Android Open Source Project 3*5a923131SAndroid Build Coastguard Worker# 4*5a923131SAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 5*5a923131SAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 6*5a923131SAndroid Build Coastguard Worker# You may obtain a copy of the License at 7*5a923131SAndroid Build Coastguard Worker# 8*5a923131SAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 9*5a923131SAndroid Build Coastguard Worker# 10*5a923131SAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 11*5a923131SAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 12*5a923131SAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*5a923131SAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 14*5a923131SAndroid Build Coastguard Worker# limitations under the License. 15*5a923131SAndroid Build Coastguard Worker# 16*5a923131SAndroid Build Coastguard Worker 17*5a923131SAndroid Build Coastguard Workerdescription "System software update service" 18*5a923131SAndroid Build Coastguard Workerauthor "[email protected]" 19*5a923131SAndroid Build Coastguard Worker 20*5a923131SAndroid Build Coastguard Worker# N.B. The chromeos-factoryinstall ebuild edits the 'start on' line so as 21*5a923131SAndroid Build Coastguard Worker# to disable update_engine in factory images. Do not change this without 22*5a923131SAndroid Build Coastguard Worker# also updating that reference. 23*5a923131SAndroid Build Coastguard Workerstart on starting system-services 24*5a923131SAndroid Build Coastguard Workerstop on stopping system-services 25*5a923131SAndroid Build Coastguard Worker# The default is 10 failures every 5 seconds, but even if we crash early, it is 26*5a923131SAndroid Build Coastguard Worker# hard to catch that. So here we set the crash rate as 10 failures every 20 27*5a923131SAndroid Build Coastguard Worker# seconds which will include the default and more. 28*5a923131SAndroid Build Coastguard Workerrespawn 29*5a923131SAndroid Build Coastguard Workerrespawn limit 10 20 30*5a923131SAndroid Build Coastguard Worker 31*5a923131SAndroid Build Coastguard Workerexpect fork 32*5a923131SAndroid Build Coastguard Worker 33*5a923131SAndroid Build Coastguard Worker# Runs the daemon at low/idle IO priority so that updates don't 34*5a923131SAndroid Build Coastguard Worker# impact system responsiveness. 35*5a923131SAndroid Build Coastguard Workerexec ionice -c3 update_engine 36*5a923131SAndroid Build Coastguard Worker 37*5a923131SAndroid Build Coastguard Worker# Put update_engine process in its own cgroup. 38*5a923131SAndroid Build Coastguard Worker# Default cpu.shares is 1024. 39*5a923131SAndroid Build Coastguard Workerpost-start script 40*5a923131SAndroid Build Coastguard Worker pid=$(status | cut -f 4 -d ' ') 41*5a923131SAndroid Build Coastguard Worker 42*5a923131SAndroid Build Coastguard Worker cgroup_cpu_dir="/sys/fs/cgroup/cpu/${UPSTART_JOB}" 43*5a923131SAndroid Build Coastguard Worker mkdir -p "${cgroup_cpu_dir}" 44*5a923131SAndroid Build Coastguard Worker echo ${pid} > "${cgroup_cpu_dir}/tasks" 45*5a923131SAndroid Build Coastguard Worker 46*5a923131SAndroid Build Coastguard Worker # Assigns net_cls handle 1:1 to packets generated from update_engine. For 47*5a923131SAndroid Build Coastguard Worker # routing and tagging purposes, that value will be redefined in 48*5a923131SAndroid Build Coastguard Worker # patchpanel/routing_service.h . 49*5a923131SAndroid Build Coastguard Worker cgroup_net_cls_dir="/sys/fs/cgroup/net_cls/${UPSTART_JOB}" 50*5a923131SAndroid Build Coastguard Worker mkdir -p "${cgroup_net_cls_dir}" 51*5a923131SAndroid Build Coastguard Worker echo ${pid} > "${cgroup_net_cls_dir}/tasks" 52*5a923131SAndroid Build Coastguard Worker echo "0x10001" > "${cgroup_net_cls_dir}/net_cls.classid" 53*5a923131SAndroid Build Coastguard Workerend script 54