diff --git a/runbot/models/host.py b/runbot/models/host.py
index 53c363473..fcccfc6b7 100644
--- a/runbot/models/host.py
+++ b/runbot/models/host.py
@@ -394,6 +394,14 @@ def _get_builds(self, domain, order=None):
def _process_messages(self):
return self.host_message_ids._process()
+ def _action_pause(self):
+ for host in self:
+ host.paused = True
+
+ def _action_unpause(self):
+ for host in self:
+ host.paused = False
+
class MessageQueue(models.Model):
_name = 'runbot.host.message'
diff --git a/runbot/views/host_views.xml b/runbot/views/host_views.xml
index 726aeff48..f24647aa2 100644
--- a/runbot/views/host_views.xml
+++ b/runbot/views/host_views.xml
@@ -63,7 +63,7 @@
-
+
@@ -75,5 +75,28 @@
host
+
+ Pause Selected Hosts
+
+
+ ir.actions.server
+ code
+
+ action = records._action_pause()
+
+
+
+
+ Unpause Selected Hosts
+
+
+ ir.actions.server
+ code
+
+ action = records._action_unpause()
+
+
+
+
diff --git a/runbot_builder/tools.py b/runbot_builder/tools.py
index 4fd018fd0..9a1295405 100644
--- a/runbot_builder/tools.py
+++ b/runbot_builder/tools.py
@@ -16,6 +16,7 @@
from pathlib import Path
from logging.handlers import WatchedFileHandler
+
LOG_FORMAT = '%(asctime)s %(levelname)s %(name)s: %(message)s'
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
logging.getLogger('odoo.addons.runbot').setLevel(logging.DEBUG)
@@ -40,6 +41,7 @@ def on_start(self):
def main_loop(self):
from odoo import fields
from odoo.tools.profiler import Profiler
+ from odoo.tools.misc import str2bool
self.on_start()
signal.signal(signal.SIGINT, self.signal_handler)
signal.signal(signal.SIGTERM, self.signal_handler)
@@ -55,6 +57,11 @@ def main_loop(self):
' (assigned only)' if self.host.assigned_only else ''
)
while True:
+ if str2bool(self.env['ir.config_parameter'].sudo().get_param('pause_all_hosts', 'False')):
+ # don't even access hosts to make upgrades possible
+ _logger.info('All hosts are paused, sleeping 10s')
+ self.sleep(10)
+ continue
context_manager = Profiler(db=self.env.cr.dbname) if self.host.profile else nullcontext()
with context_manager:
try: