1#! /usr/bin/env python 2# Copyright 2015 The Chromium Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6import os 7import subprocess 8import sys 9import time 10 11 12sys.path.append(os.path.dirname(os.path.realpath(__file__))) 13import packaging 14 15 16def main(): 17 root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) 18 with packaging.TempAppDir(root_dir, symlinks=True) as temp_app_dir: 19 yaml_files = list(file_name for file_name in packaging.Yamls(temp_app_dir) 20 if os.path.basename(file_name) != 'cron.yaml') 21 args = ['dev_appserver.py'] + yaml_files + sys.argv[1:] 22 23 server = subprocess.Popen(args, cwd=temp_app_dir) 24 try: 25 server.wait() 26 except KeyboardInterrupt: 27 server.wait() 28 # It's pretty much impossible to wait for all the subprocesses of the dev 29 # server to finish, as they all shut down asynchronously. But their 30 # shutdown timeouts are generally 1 second, so that's probably enough. 31 time.sleep(1) 32 33 34if __name__ == '__main__': 35 main() 36