blob: 0f477c8b49ac98e1f5452102fb32c8c321252f67 [file] [log] [blame]
# Copyright (c) 2011 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 "Collects boot data and optionally creates a chart"
author ""
# Job bootchart is started before job pre-startup for covering as much as
# possible of the boot.
start on starting pre-startup
# A lot of services start via "start on started system-services" which is
# why we use a pre-stop sleep below. That should gather some data even on
# non-critical (UI/login blocking) services.
stop on started system-services
# Use /dev/ file system for temporary files because /tmp/ and /run/ are not yet
# mounted in job pre-startup.
env BC_RUN=/dev/.bootchart
env BC_LOG=/var/log/bootchart
pre-start script
# Bootchart is disabled by default and is enabled only in the boot perf test.
# To enable bootchart, add "cros_bootchart" to kernel args.
if grep -qs 'cros_bootchart' /proc/cmdline; then
mkdir -p "${BC_RUN}"
end script
exec /lib/bootchart/collector 25 "${BC_RUN}"
# See "stop on" comment above.
pre-stop exec sleep 10
post-stop script
if [ -d "${BC_RUN}" ]; then
BC_DATA="${BC_LOG}/boot-$(date +%Y%m%d-%H%M%S).tgz"
mkdir -p "${BC_LOG}"
/lib/bootchart/gather "${BC_DATA}" "${BC_RUN}"
rm -rf "${BC_RUN}"
end script