blob: 46c3839ddce8b500db4a32b2f8d1a5f7c8d6f97e [file] [log] [blame]
Scott Zawalski20a9b582011-11-21 11:49:40 -08001#!/bin/bash
2#
3# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6#
7# Author: Dale Curtis (dalecurtis@google.com)
8#
9# Small cron script which uses a PID file to check if Dev Server is running. If
10# not, the Dev Server is started and the PID is recorded.
11#
12# Script is written with the layout of Kirkland test lab's Dev Server in mind.
13#
14
15
16# Path to Dev Server source code.
17declare -r DEV_SERVER_PATH="/usr/local/google/chromeos/src/platform/dev/"
18
19# Path to Dev Server images directory.
20declare -r IMAGES_PATH="/usr/local/google/images"
21
22# PID file location.
23declare -r PID_FILE="/tmp/dev_server.pid"
24
25
26function start_dev_server {
27 echo "Starting a new Dev Server instance..."
28 cd ${DEV_SERVER_PATH}
Chris Sosaef819232012-08-21 15:08:21 -070029 python devserver.py 8080 --archive_dir ${IMAGES_PATH} -t &>/dev/null&
Scott Zawalski20a9b582011-11-21 11:49:40 -080030 echo $!>${PID_FILE}
31}
32
33
34# First check for PID file, then check if PID is valid. If either are false,
35# start a new Dev Server instance.
36if [ -f ${PID_FILE} ]; then
37 ps $(cat ${PID_FILE}) | grep -q devserver.py || start_dev_server
38else
39 start_dev_server
40fi