|
43 | 43 | _re_warning = r'^\d{4}-\d\d-\d\d \d\d:\d\d:\d\d,\d{3} \d+ WARNING ' |
44 | 44 | _re_job = re.compile('job_\d') |
45 | 45 |
|
| 46 | +# monkey patch cron system to reduce starvation and improve throughput with many workers |
| 47 | +openerp.service.server.SLEEP_INTERVAL = 4 |
46 | 48 |
|
47 | 49 | #---------------------------------------------------------- |
48 | 50 | # RunBot helpers |
@@ -179,11 +181,10 @@ def _get_base(self, cr, uid, ids, field_name, arg, context=None): |
179 | 181 | 'path': fields.function(_get_path, type='char', string='Directory', readonly=1), |
180 | 182 | 'base': fields.function(_get_base, type='char', string='Base URL', readonly=1), |
181 | 183 | 'nginx': fields.boolean('Nginx'), |
182 | | - 'auto': fields.boolean('Auto'), |
183 | | - 'mode': fields.selection([('disabled', 'Dont check for new build'), |
184 | | - ('poll', 'Poll git repository'), |
185 | | - ('hook', 'Wait for webhook on /runbot/hook/<id> i.e. github push event')], |
186 | | - string="Mode"), |
| 184 | + 'mode': fields.selection([('disabled', 'Disabled'), |
| 185 | + ('poll', 'Poll'), |
| 186 | + ('hook', 'Hook')], |
| 187 | + string="Mode", required=True, help="hook: Wait for webhook on /runbot/hook/<id> i.e. github push event"), |
187 | 188 | 'hook_time': fields.datetime('Last hook time'), |
188 | 189 | 'duplicate_id': fields.many2one('runbot.repo', 'Duplicate repo', help='Repository for finding duplicate builds'), |
189 | 190 | 'modules': fields.char("Modules to install", help="Comma-separated list of modules to install and test."), |
@@ -273,6 +274,8 @@ def update_git(self, cr, uid, repo, context=None): |
273 | 274 | # check for mode == hook |
274 | 275 | fetch_time = os.path.getmtime(os.path.join(repo.path, 'FETCH_HEAD')) |
275 | 276 | if repo.mode == 'hook' and repo.hook_time and dt2time(repo.hook_time) < fetch_time: |
| 277 | + t0 = time.time() |
| 278 | + _logger.debug('repo %s skip hook fetch fetch_time: %ss ago hook_time: %ss ago', repo.name, int(t0 - fetch_time), int(t0 - dt2time(repo.hook_time))) |
276 | 279 | return |
277 | 280 |
|
278 | 281 | repo.git(['gc', '--auto', '--prune=all']) |
@@ -1227,10 +1230,11 @@ def branch_info(branch): |
1227 | 1230 |
|
1228 | 1231 | return request.render("runbot.repo", context) |
1229 | 1232 |
|
1230 | | - @http.route(['/runbot', '/runbot/hook/<repo_id:int>'], type='http', auth="public", website=True) |
1231 | | - def repo(self, repo_id=None, **post): |
1232 | | - repo = request.registry['runbot.repo'].browse(cr, SUPERUSER_ID, [repo_id]) |
1233 | | - repo.hook_time = datetime.now().strftime(DEFAULT_SERVER_DATETIME_FORMAT) |
| 1233 | + @http.route(['/runbot/hook/<int:repo_id>'], type='http', auth="public", website=True) |
| 1234 | + def hook(self, repo_id=None, **post): |
| 1235 | + # TODO if repo_id == None parse the json['repository']['ssh_url'] and find the right repo |
| 1236 | + repo = request.registry['runbot.repo'].browse(request.cr, SUPERUSER_ID, [repo_id]) |
| 1237 | + repo.hook_time = datetime.datetime.now().strftime(openerp.tools.DEFAULT_SERVER_DATETIME_FORMAT) |
1234 | 1238 | return "" |
1235 | 1239 |
|
1236 | 1240 | @http.route(['/runbot/dashboard'], type='http', auth="public", website=True) |
|
0 commit comments