code: def api_rebuild():
      
      if db is None:
          return '{"error": "single-user mode"}'
      build_job = q.fetch_job('build')
      orphans_job = q.fetch_job('orphans')
  
      if not build_job and not orphans_job:
          build_job = q.enqueue_call(func=coil.tasks.build,
                                     args=(app.config['REDIS_URL'],
                                           app.config['NIKOLA_ROOT'],
                                           ''),
                                     job_id='build')
          orphans_job = q.enqueue_call(func=coil.tasks.orphans,
                                       args=(app.config['REDIS_URL'],
                                             app.config['NIKOLA_ROOT']),
                                       job_id='orphans', depends_on=build_job)
  
      d = json.dumps({'build': build_job.meta, 'orphans': orphans_job.meta})
  
      if ('status' in build_job.meta and
              build_job.meta['status'] is not None and
              'status' in orphans_job.meta and
              orphans_job.meta['status'] is not None):
          rq.cancel_job('build', db)
          rq.cancel_job('orphans', db)
          db.set('site:needs_rebuild', '0')
          site.coil_needs_rebuild = '1'
  
      return d
docs: Rebuild the site (internally).