OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Platform-specific utility methods shared by several scripts.""" | 6 """Platform-specific utility methods shared by several scripts.""" |
7 | 7 |
8 import os | 8 import os |
9 import subprocess | 9 import subprocess |
10 | 10 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 'httpd_config', 'httpd2.pem') | 83 'httpd_config', 'httpd2.pem') |
84 httpd_vars = { | 84 httpd_vars = { |
85 "httpd_executable_path": | 85 "httpd_executable_path": |
86 os.path.join(self._UnixRoot(), "usr", "sbin", exe_name), | 86 os.path.join(self._UnixRoot(), "usr", "sbin", exe_name), |
87 "httpd_conf_path": httpd_conf_path, | 87 "httpd_conf_path": httpd_conf_path, |
88 "ssl_certificate_file": cert_file, | 88 "ssl_certificate_file": cert_file, |
89 "document_root" : document_root, | 89 "document_root" : document_root, |
90 "server_root": os.path.join(self._UnixRoot(), "usr"), | 90 "server_root": os.path.join(self._UnixRoot(), "usr"), |
91 "mime_types_path": mime_types_path, | 91 "mime_types_path": mime_types_path, |
92 "output_dir": output_dir, | 92 "output_dir": output_dir, |
| 93 "ssl_mutex": "file:"+os.path.join(output_dir, "ssl_mutex"), |
93 "user": os.environ.get("USER", "#%d" % os.geteuid()), | 94 "user": os.environ.get("USER", "#%d" % os.geteuid()), |
94 "lock_file": os.path.join(output_dir, "accept.lock"), | 95 "lock_file": os.path.join(output_dir, "accept.lock"), |
95 } | 96 } |
96 | 97 |
97 google.path_utils.MaybeMakeDirectory(output_dir) | 98 google.path_utils.MaybeMakeDirectory(output_dir) |
98 | 99 |
99 # We have to wrap the command in bash | 100 # We have to wrap the command in bash |
100 # -C: process directive before reading config files | 101 # -C: process directive before reading config files |
101 # -c: process directive after reading config files | 102 # -c: process directive after reading config files |
102 # Apache wouldn't run CGIs with permissions==700 unless we add | 103 # Apache wouldn't run CGIs with permissions==700 unless we add |
103 # -c User "<username>" | 104 # -c User "<username>" |
104 httpd_cmd_string = ( | 105 httpd_cmd_string = ( |
105 '%(httpd_executable_path)s' | 106 '%(httpd_executable_path)s' |
106 ' -f %(httpd_conf_path)s' | 107 ' -f %(httpd_conf_path)s' |
107 ' -c \'TypesConfig "%(mime_types_path)s"\'' | 108 ' -c \'TypesConfig "%(mime_types_path)s"\'' |
108 ' -c \'CustomLog "%(output_dir)s/access_log.txt" common\'' | 109 ' -c \'CustomLog "%(output_dir)s/access_log.txt" common\'' |
109 ' -c \'ErrorLog "%(output_dir)s/error_log.txt"\'' | 110 ' -c \'ErrorLog "%(output_dir)s/error_log.txt"\'' |
110 ' -c \'PidFile "%(output_dir)s/httpd.pid"\'' | 111 ' -c \'PidFile "%(output_dir)s/httpd.pid"\'' |
111 ' -C \'User "%(user)s"\'' | 112 ' -C \'User "%(user)s"\'' |
112 ' -C \'ServerRoot "%(server_root)s"\'' | 113 ' -C \'ServerRoot "%(server_root)s"\'' |
113 ' -c \'LockFile "%(lock_file)s"\'' | 114 ' -c \'LockFile "%(lock_file)s"\'' |
114 ' -c \'SSLCertificateFile "%(ssl_certificate_file)s"\'' | 115 ' -c \'SSLCertificateFile "%(ssl_certificate_file)s"\'' |
| 116 ' -c \'SSLMutex "%(ssl_mutex)s"\'' |
115 ) | 117 ) |
116 | 118 |
117 if document_root: | 119 if document_root: |
118 httpd_cmd_string += ' -C \'DocumentRoot "%(document_root)s"\'' | 120 httpd_cmd_string += ' -C \'DocumentRoot "%(document_root)s"\'' |
119 # Save a copy of httpd_cmd_string to use for stopping httpd | 121 # Save a copy of httpd_cmd_string to use for stopping httpd |
120 self._httpd_cmd_string = httpd_cmd_string % httpd_vars | 122 self._httpd_cmd_string = httpd_cmd_string % httpd_vars |
121 | 123 |
122 httpd_cmd = [self._bash, "-c", self._httpd_cmd_string] | 124 httpd_cmd = [self._bash, "-c", self._httpd_cmd_string] |
123 return httpd_cmd | 125 return httpd_cmd |
124 | 126 |
125 def GetStopHttpdCommand(self): | 127 def GetStopHttpdCommand(self): |
126 """Returns a list of strings that contains the command line+args needed to | 128 """Returns a list of strings that contains the command line+args needed to |
127 stop the http server used in the http tests. | 129 stop the http server used in the http tests. |
128 | 130 |
129 This tries to fetch the pid of httpd (if available) and returns the | 131 This tries to fetch the pid of httpd (if available) and returns the |
130 command to kill it. If pid is not available, kill all httpd processes | 132 command to kill it. If pid is not available, kill all httpd processes |
131 """ | 133 """ |
132 | 134 |
133 if not self._httpd_cmd_string: | 135 if not self._httpd_cmd_string: |
134 return ["true"] # Haven't been asked for the start cmd yet. Just pass. | 136 return ["true"] # Haven't been asked for the start cmd yet. Just pass. |
135 # Add a sleep after the shutdown because sometimes it takes some time for | 137 # Add a sleep after the shutdown because sometimes it takes some time for |
136 # the port to be available again. | 138 # the port to be available again. |
137 return [self._bash, "-c", self._httpd_cmd_string + ' -k stop && sleep 5'] | 139 return [self._bash, "-c", self._httpd_cmd_string + ' -k stop && sleep 5'] |
OLD | NEW |