Perf dashboard should have the capability to test local UI with production data
[WebKit-https.git] / Websites / perf.webkit.org / tools / run-with-remote-server.py
1 #!/usr/bin/python
2
3 import json
4 import os
5 import subprocess
6 import tempfile
7
8
9 def main():
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')
17
18         if not os.path.isdir(cache_dir):
19             os.makedirs(cache_dir)
20         os.chmod(cache_dir, 0755)
21
22         httpd_mutax_dir = tempfile.mkdtemp()
23         try:
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,
30                 '-X'])
31         finally:
32             os.rmdir(httpd_mutax_dir)
33
34
35 def abspath_from_root(relpath):
36     return os.path.abspath(os.path.join(os.path.dirname(__file__), '../', relpath))
37
38
39 if __name__ == "__main__":
40     main()