Skip to content

Commit d75847e

Browse files
committed
[IMP] runbot: allow runbot builder to handle sighup
When the main nginx process is is restarted e.g. during unattended upgrades, it happens that the nginx process handled by the runbot builder needs to be restarted. Otherwise we loose conections with running instances. With this commit, the runbot builder now handles the SIGHUP signal and reloads restart its nginx process in that case. That way, the main nginx service could be configured to send a SIGHUP signal to the runbot builder service.
1 parent ffde0c7 commit d75847e

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

runbot/models/runbot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def _allocate_builds(self, host, nb_slots, domain=None):
152152
RETURNING id""", host.name, query.select(), nb_slots))
153153
return self.env.cr.fetchall()
154154

155-
def _reload_nginx(self):
155+
def _reload_nginx(self, force=False):
156156
env = self.env
157157
settings = {}
158158
settings['port'] = config.get('http_port')
@@ -174,7 +174,7 @@ def _reload_nginx(self):
174174
if os.path.isfile(nginx_conf_path):
175175
with file_open(nginx_conf_path, 'r') as f:
176176
content = f.read()
177-
if content != nginx_config:
177+
if content != nginx_config or force:
178178
_logger.info('reload nginx')
179179
with open(nginx_conf_path, 'w') as f:
180180
f.write(str(nginx_config))

runbot_builder/tools.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def main_loop(self):
4444
signal.signal(signal.SIGINT, self.signal_handler)
4545
signal.signal(signal.SIGTERM, self.signal_handler)
4646
signal.signal(signal.SIGQUIT, self.dump_stack)
47+
signal.signal(signal.SIGHUP, self.reload)
4748
self.host = self.env['runbot.host']._get_current()
4849
self.update_next_git_gc_date()
4950
self.host._bootstrap()
@@ -96,6 +97,9 @@ def dump_stack(self, _signal, _frame):
9697
import odoo
9798
odoo.tools.misc.dumpstacks()
9899

100+
def reload(self):
101+
self.env['runbot.runbot']._reload_nginx(force=True)
102+
99103
def sleep(self, t):
100104
self.ask_interrupt.wait(t)
101105

0 commit comments

Comments
 (0)