bitbake: toaster: runbuilds Write the pidfile in python rather than shell script
Write the pid file out in the start up of this management command. This ensures this has happened instead of relying on the shell command having been run which may or may not be the case. This also makes it simpler for testing. Couple of clean ups of runbuilds as identified by pyflake (Bitbake rev: 999e980ee1a58d16f33ef6c0e41aecdcd0206f39) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
ddaac5e4e3
commit
310a9e5d35
|
@ -254,7 +254,7 @@ case $CMD in
|
||||||
return 4
|
return 4
|
||||||
fi
|
fi
|
||||||
export BITBAKE_UI='toasterui'
|
export BITBAKE_UI='toasterui'
|
||||||
$MANAGE runbuilds & echo $! >${BUILDDIR}/.runbuilds.pid
|
$MANAGE runbuilds &
|
||||||
# set fail safe stop system on terminal exit
|
# set fail safe stop system on terminal exit
|
||||||
trap stop_system SIGHUP
|
trap stop_system SIGHUP
|
||||||
echo "Successful ${CMD}."
|
echo "Successful ${CMD}."
|
||||||
|
|
|
@ -11,9 +11,11 @@ from orm.models import Build, LogMessage, Target
|
||||||
import logging
|
import logging
|
||||||
import traceback
|
import traceback
|
||||||
import signal
|
import signal
|
||||||
|
import os
|
||||||
|
|
||||||
logger = logging.getLogger("toaster")
|
logger = logging.getLogger("toaster")
|
||||||
|
|
||||||
|
|
||||||
class Command(NoArgsCommand):
|
class Command(NoArgsCommand):
|
||||||
args = ""
|
args = ""
|
||||||
help = "Schedules and executes build requests as possible. "\
|
help = "Schedules and executes build requests as possible. "\
|
||||||
|
@ -50,7 +52,7 @@ class Command(NoArgsCommand):
|
||||||
logger.debug("runbuilds: No build env")
|
logger.debug("runbuilds: No build env")
|
||||||
return
|
return
|
||||||
|
|
||||||
logger.info("runbuilds: starting build %s, environment %s" % \
|
logger.info("runbuilds: starting build %s, environment %s" %
|
||||||
(br, bec.be))
|
(br, bec.be))
|
||||||
|
|
||||||
# let the build request know where it is being executed
|
# let the build request know where it is being executed
|
||||||
|
@ -80,7 +82,7 @@ class Command(NoArgsCommand):
|
||||||
|
|
||||||
def archive(self):
|
def archive(self):
|
||||||
for br in BuildRequest.objects.filter(state=BuildRequest.REQ_ARCHIVE):
|
for br in BuildRequest.objects.filter(state=BuildRequest.REQ_ARCHIVE):
|
||||||
if br.build == None:
|
if br.build is None:
|
||||||
br.state = BuildRequest.REQ_FAILED
|
br.state = BuildRequest.REQ_FAILED
|
||||||
else:
|
else:
|
||||||
br.state = BuildRequest.REQ_COMPLETED
|
br.state = BuildRequest.REQ_COMPLETED
|
||||||
|
@ -99,10 +101,10 @@ class Command(NoArgsCommand):
|
||||||
Q(updated__lt=timezone.now() - timedelta(seconds=30))
|
Q(updated__lt=timezone.now() - timedelta(seconds=30))
|
||||||
).update(lock=BuildEnvironment.LOCK_FREE)
|
).update(lock=BuildEnvironment.LOCK_FREE)
|
||||||
|
|
||||||
|
|
||||||
# update all Builds that were in progress and failed to start
|
# update all Builds that were in progress and failed to start
|
||||||
for br in BuildRequest.objects.filter(state=BuildRequest.REQ_FAILED,
|
for br in BuildRequest.objects.filter(
|
||||||
build__outcome=Build.IN_PROGRESS):
|
state=BuildRequest.REQ_FAILED,
|
||||||
|
build__outcome=Build.IN_PROGRESS):
|
||||||
# transpose the launch errors in ToasterExceptions
|
# transpose the launch errors in ToasterExceptions
|
||||||
br.build.outcome = Build.FAILED
|
br.build.outcome = Build.FAILED
|
||||||
for brerror in br.brerror_set.all():
|
for brerror in br.brerror_set.all():
|
||||||
|
@ -117,7 +119,6 @@ class Command(NoArgsCommand):
|
||||||
br.environment.lock = BuildEnvironment.LOCK_FREE
|
br.environment.lock = BuildEnvironment.LOCK_FREE
|
||||||
br.environment.save()
|
br.environment.save()
|
||||||
|
|
||||||
|
|
||||||
# update all BuildRequests without a build created
|
# update all BuildRequests without a build created
|
||||||
for br in BuildRequest.objects.filter(build=None):
|
for br in BuildRequest.objects.filter(build=None):
|
||||||
br.build = Build.objects.create(project=br.project,
|
br.build = Build.objects.create(project=br.project,
|
||||||
|
@ -144,7 +145,7 @@ class Command(NoArgsCommand):
|
||||||
|
|
||||||
# Make sure the LOCK is removed for builds which have been fully
|
# Make sure the LOCK is removed for builds which have been fully
|
||||||
# cancelled
|
# cancelled
|
||||||
for br in BuildRequest.objects.filter(\
|
for br in BuildRequest.objects.filter(
|
||||||
Q(build__outcome=Build.CANCELLED) &
|
Q(build__outcome=Build.CANCELLED) &
|
||||||
Q(state=BuildRequest.REQ_CANCELLING) &
|
Q(state=BuildRequest.REQ_CANCELLING) &
|
||||||
~Q(environment=None)):
|
~Q(environment=None)):
|
||||||
|
@ -168,6 +169,12 @@ class Command(NoArgsCommand):
|
||||||
logger.warn("runbuilds: schedule exception %s" % str(e))
|
logger.warn("runbuilds: schedule exception %s" % str(e))
|
||||||
|
|
||||||
def handle_noargs(self, **options):
|
def handle_noargs(self, **options):
|
||||||
|
pidfile_path = os.path.join(os.environ.get("BUILDDIR", "."),
|
||||||
|
".runbuilds.pid")
|
||||||
|
|
||||||
|
with open(pidfile_path, 'w') as pidfile:
|
||||||
|
pidfile.write("%s" % os.getpid())
|
||||||
|
|
||||||
self.runbuild()
|
self.runbuild()
|
||||||
|
|
||||||
signal.signal(signal.SIGUSR1, lambda sig, frame: None)
|
signal.signal(signal.SIGUSR1, lambda sig, frame: None)
|
||||||
|
|
|
@ -90,7 +90,6 @@ class Command(NoArgsCommand):
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
|
|
||||||
proxy_settings = os.environ.get("http_proxy", None)
|
proxy_settings = os.environ.get("http_proxy", None)
|
||||||
oe_core_layer = 'openembedded-core'
|
|
||||||
|
|
||||||
def _get_json_response(apiurl=DEFAULT_LAYERINDEX_SERVER):
|
def _get_json_response(apiurl=DEFAULT_LAYERINDEX_SERVER):
|
||||||
http_progress = Spinner()
|
http_progress = Spinner()
|
||||||
|
|
Loading…
Reference in New Issue