<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def start(self):
 """ start the scheduler """

        #  demonize
        if self.run_as_daemon:
            if not self.demonize():
                self.delete_pid()
                sys.exit(0)
        # recreate the DB connection
        if connection.connection is not None:
            connection.connection.close()
            connection.connection = None
        master_process = BackgroundProcess.objects.filter(parent_process__isnull=True,
                                                          label=self.label,
                                                          enabled=True).first()
        self.pid = getpid()
        if not master_process:
            self.delete_pid(force_del=True)
            logger.debug('no such process in BackgroundProcesses\n')
            sys.exit(0)

        self.process_id = master_process.pk
        master_process.pid = self.pid
        master_process.last_update = now()
        master_process.running_since = now()
        master_process.done = False
        master_process.failed = False
        master_process.message = 'init master process'
        master_process.save()
        BackgroundProcess.objects.filter(parent_process__pk=self.process_id, done=False).update(message='stopped')
        for parent_process in BackgroundProcess.objects.filter(parent_process__pk=self.process_id, done=False):
            for process in BackgroundProcess.objects.filter(parent_process__pk=parent_process.pk, done=False):
                try:
                    kill(process.pid, 0)
                except OSError as e:
                    if e.errno == errno.ESRCH:
                        process.delete()
                        continue
                logger.debug('process %d is alive' % process.pk)
                process.stop()

            # clean up
            BackgroundProcess.objects.filter(parent_process__pk=parent_process.pk, done=False).delete()

        # register signals
        [signal.signal(s, self.signal) for s in self.SIGNALS]
        #signal.signal(signal.SIGCHLD, self.handle_chld)
        # start the main loop
        self.run()
        self.delete_pid()
        sys.exit(0)