mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-14 06:52:39 +03:00
build: enable watchdog timer for each build that kills in 2 hours
This introduces locking for the commonly used vagrant functions in vmtools because vagrant fails when another vagrant command is already running.
This commit is contained in:
parent
9a4f3ac019
commit
85985074d4
2 changed files with 37 additions and 12 deletions
|
@ -29,6 +29,9 @@ from .common import FDroidException
|
|||
from logging import getLogger
|
||||
|
||||
from fdroidserver import _
|
||||
import threading
|
||||
|
||||
lock = threading.Lock()
|
||||
|
||||
logger = getLogger('fdroidserver-vmtools')
|
||||
|
||||
|
@ -175,7 +178,6 @@ class FDroidBuildVm():
|
|||
This is intended to be a hypervisor independant, fault tolerant
|
||||
wrapper around the vagrant functions we use.
|
||||
"""
|
||||
|
||||
def __init__(self, srvdir):
|
||||
"""Create new server class.
|
||||
"""
|
||||
|
@ -191,21 +193,27 @@ class FDroidBuildVm():
|
|||
self.vgrnt = vagrant.Vagrant(root=srvdir, out_cm=vagrant.stdout_cm, err_cm=vagrant.stdout_cm)
|
||||
|
||||
def up(self, provision=True):
|
||||
try:
|
||||
self.vgrnt.up(provision=provision)
|
||||
self.srvuuid = self._vagrant_fetch_uuid()
|
||||
except subprocess.CalledProcessError as e:
|
||||
raise FDroidBuildVmException("could not bring up vm '%s'" % self.srvname) from e
|
||||
global lock
|
||||
with lock:
|
||||
try:
|
||||
self.vgrnt.up(provision=provision)
|
||||
self.srvuuid = self._vagrant_fetch_uuid()
|
||||
except subprocess.CalledProcessError as e:
|
||||
raise FDroidBuildVmException("could not bring up vm '%s'" % self.srvname) from e
|
||||
|
||||
def suspend(self):
|
||||
logger.info('suspending buildserver')
|
||||
try:
|
||||
self.vgrnt.suspend()
|
||||
except subprocess.CalledProcessError as e:
|
||||
raise FDroidBuildVmException("could not suspend vm '%s'" % self.srvname) from e
|
||||
global lock
|
||||
with lock:
|
||||
logger.info('suspending buildserver')
|
||||
try:
|
||||
self.vgrnt.suspend()
|
||||
except subprocess.CalledProcessError as e:
|
||||
raise FDroidBuildVmException("could not suspend vm '%s'" % self.srvname) from e
|
||||
|
||||
def halt(self):
|
||||
self.vgrnt.halt(force=True)
|
||||
global lock
|
||||
with lock:
|
||||
self.vgrnt.halt(force=True)
|
||||
|
||||
def destroy(self):
|
||||
"""Remove every trace of this VM from the system.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue