Home | History | Annotate | Download | only in admin
      1 #!/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 (at] 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.
     17 declare -r DEV_SERVER_PATH="/usr/local/google/chromeos/src/platform/dev/"
     18 
     19 # Path to Dev Server images directory.
     20 declare -r IMAGES_PATH="/usr/local/google/images"
     21 
     22 # PID file location.
     23 declare -r PID_FILE="/tmp/dev_server.pid"
     24 
     25 
     26 function start_dev_server {
     27   echo "Starting a new Dev Server instance..."
     28   cd ${DEV_SERVER_PATH}
     29   python devserver.py 8080 --archive_dir ${IMAGES_PATH} -t &>/dev/null&
     30   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.
     36 if [ -f ${PID_FILE} ]; then
     37   ps $(cat ${PID_FILE}) | grep -q devserver.py || start_dev_server
     38 else
     39   start_dev_server
     40 fi
     41