예제 #1
0
    def shutdown(self):
        os.chdir(self.site.build_dir)
        shell('bin/supervisorctl shutdown', False)
        pidfile = 'var/supervisord.pid'
        while os.path.exists(pidfile):
            # If we have a proc filesystem, we can make sure it isn't a stale
            # pid file
            if os.path.exists('/proc'):
                pid = open(pidfile).read().strip()
                procpid = '/proc/%s' % pid
                if not os.path.exists(procpid):
                    log.warn("Removing stale supervisord.pid")
                    os.remove(pidfile)
                    break

            log.info("Waiting for supervisor to shutdown...")
            time.sleep(1)
예제 #2
0
 def startup(self):
     os.chdir(self.site.build_dir)
     shell('bin/supervisord')
예제 #3
0
    def checkout_sources(self, main_branch, branches):
        src = os.path.join(self.build_dir, self.harness.sources_dir)
        if not os.path.exists(src):
            os.mkdir(src)
        sources = self.harness.sources
        branches[sources[0]['name']] = main_branch
        for source in sources:
            name = source['name']
            default = 'master' if name in self.harness.always_checkout else None
            branch = branches.get(name, default)
            if branch is None:
                continue
            source_dir = os.path.join(src, name)
            if os.path.exists(source_dir):
                continue

            # Use cache, so most objects can be copied locally in most cases
            cachedir = os.path.join(self.harness.var, 'gitcache')
            url = source['url']
            if not os.path.exists(cachedir):
                os.mkdir(cachedir)
            cacherepo = os.path.join(cachedir, name) + '.git'
            if not os.path.exists(cacherepo):
                os.chdir(cachedir)
                shell('git clone --mirror %s %s.git' % (url, name))
            else:
                os.chdir(cacherepo)
                shell('git fetch')

            os.chdir(src)
            shell('git clone --branch %s %s' % (branch, cacherepo))
            os.chdir(source_dir)
            shell('git remote rm origin')
            shell('git remote add origin %s' % url)
            shell('git config branch.%s.remote origin' % branch)
            shell('git config branch.%s.merge refs/heads/%s' % (
                branch, branch))
            shell('git pull')