[IMP] runbot: allow nginx access to tests dir

In order to stores other things than logs, that could be accessible by
end users, for example screenshots and screencasts, a "tests" directory
is allowed thruough the nginx template in the builds directories.

Also, the "with" context manager is used to open the nginx configuration
to ensure that the file descriptor is released during long running crons.
This commit is contained in:
Christophe Monniez 2019-07-18 14:39:38 +02:00
parent 287efc7989
commit c3e23532be
2 changed files with 3 additions and 2 deletions

View File

@ -499,7 +499,8 @@ class runbot_repo(models.Model):
nginx_config = self.env['ir.ui.view'].render_template("runbot.nginx_config", settings)
os.makedirs(nginx_dir, exist_ok=True)
open(os.path.join(nginx_dir, 'nginx.conf'), 'wb').write(nginx_config)
with open(os.path.join(nginx_dir, 'nginx.conf'), 'wb') as nginx_file:
nginx_file.write(nginx_config)
try:
_logger.debug('reload nginx')
pid = int(open(os.path.join(nginx_dir, 'nginx.pid')).read().strip(' \n'))

View File

@ -39,7 +39,7 @@ server {
location /runbot/static/ {
alias <t t-esc="runbot_static"/>;
autoindex off;
location ~ /runbot/static/build/[^/]+/logs/ {
location ~ /runbot/static/build/[^/]+/(logs|tests)/ {
autoindex on;
}
}