10 with open(abspath_from_root('config.json')) as config_file:
11 config = json.load(config_file)
12 cache_dir = abspath_from_root(config['cacheDirectory'])
13 httpd_config_file = abspath_from_root(config['remoteServer']['httpdConfig'])
14 httpd_pid_file = abspath_from_root(config['remoteServer']['httpdPID'])
15 httpd_error_log_file = abspath_from_root(config['remoteServer']['httpdErroLog'])
16 doc_root = abspath_from_root('public')
18 if not os.path.isdir(cache_dir):
19 os.makedirs(cache_dir)
20 os.chmod(cache_dir, 0755)
22 httpd_mutax_dir = tempfile.mkdtemp()
24 subprocess.call(['httpd',
25 '-f', httpd_config_file,
26 '-c', 'PidFile ' + httpd_pid_file,
27 '-c', 'Mutex file:' + httpd_mutax_dir,
28 '-c', 'DocumentRoot ' + doc_root,
29 '-c', 'ErrorLog ' + httpd_error_log_file,
32 os.rmdir(httpd_mutax_dir)
35 def abspath_from_root(relpath):
36 return os.path.abspath(os.path.join(os.path.dirname(__file__), '../', relpath))
39 if __name__ == "__main__":