| # Copyright 2019 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 "Run ureadahead for arcvm" |
| author "chromium-os-dev@chromium.org" |
| |
| # Preload the arcvm image file into the page cache while users are entering |
| # their password. |
| start on login-prompt-visible |
| |
| # TODO(b/135556154): Stop this job if crosvm crashes. |
| stop on arc-booted or stopping ui |
| |
| # By default upstart gives at most 5 seconds to processes after sending them |
| # a SIGTERM before killing them which wouldn't always give enough time to |
| # ureadahead to write the trace file when it's in tracing mode. |
| kill timeout 30 |
| |
| script |
| PACK=/opt/google/vms/android/ureadahead.pack |
| |
| { |
| echo "Start arcvm-ureadahead" |
| set -x |
| |
| # Read-ahead files in the image. |
| if [ -f "${PACK}" ]; then |
| ureadahead --pack-file="${PACK}" || \ |
| echo "Failed to start ureadahead pack for ${PACK}" |
| else |
| echo "ureadahead pack is not available at ${PACK}" |
| fi |
| } 2>&1 | runcon u:r:cros_arcvm_logger:s0 logger -t "${UPSTART_JOB}" |
| end script |