mirror of
https://github.com/odoo/runbot.git
synced 2025-03-23 19:35:45 +07:00

On the actual runbot deployments, the `git gc` command is handled by a unix cron. From time to time, some repositories get corrupted and we suspect that some concurrent action may be involved as stated in documentation [0]. For those reasons, with this commit, the `git gc` will be run by the runbot clients themselves in order to avoid concurrent operations. By default, the first gc will occur a few minutes after the start of the client and the next gc are scheduled a two hours and a few minutes later. Also, this commit ensures that the git config is written regularly in case of change. [0] https://git-scm.com/docs/git-gc
25 lines
688 B
Python
Executable File
25 lines
688 B
Python
Executable File
#!/usr/bin/python3
|
|
from tools import RunbotClient, run
|
|
import logging
|
|
import time
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
class LeaderClient(RunbotClient): # Conductor, Director, Main, Maestro, Lead
|
|
def __init__(self, env):
|
|
self.pull_info_failures = {}
|
|
super().__init__(env)
|
|
|
|
def on_start(self):
|
|
self.env['runbot.repo'].search([('mode', '!=', 'disabled')])._update(force=True)
|
|
|
|
def loop_turn(self):
|
|
if self.count == 0:
|
|
self.env['runbot.repo']._update_git_config()
|
|
self.git_gc()
|
|
return self.env['runbot.runbot']._fetch_loop_turn(self.host, self.pull_info_failures)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
run(LeaderClient)
|