title: Restarting The Jobs In ApScheduler Python When the Wsgi Server is Restarted
body: <p>I'm using python Apscheduler to schedule my jobs. All my jobs are stored as a cron job and use the BackgroundScheduler. I've the following codes: </p>
  
  <pre><code>def letschedule():
      jobstores = {
          'default': SQLAlchemyJobStore(url=app_jobs_store)
      }
      executors = {
          'default': ThreadPoolExecutor(20),
          'processpool': ProcessPoolExecutor(5)
      }
      job_defaults = {
          'coalesce': False,
          'max_instances': 1,
          'misfire_grace_time':1200
      }
      scheduler = BackgroundScheduler(jobstores=jobstores, executors=executors, job_defaults=job_defaults, timezone=utc)
      #jobstores=jobstores, executors=executors, job_defaults=job_defaults, timezone=utc
      return scheduler
  </code></pre>
  
  <p>And I start the job scheduler as follow in the app: </p>
  
  <pre><code>sch = letschedule()
  sch.start()
  log.info('the scheduler started')
  </code></pre>
  
  <p>And I've the following add job function. </p>
  
  <pre><code>def addjobs():
  
  
      jobs = []
      try:
          sch.add_job(forecast_jobs, 'cron', day_of_week=os.environ.get("FORECAST_WEEKOFDAY"),  
              id="forecast",
               replace_existing=False,week='1-53',hour=os.environ.get("FORECAST_HOUR"), 
               minute=os.environ.get("FORECAST_MINUTE"), timezone='UTC')
          jobs.append({'job_id':'forecast', 'type':'weekly'})
  
          log.info('the forecast added to the scheduler')
      except BaseException as e:
          log.info(e)
          pass
      try:
          sch.add_job(insertcwhstock, 'cron', 
              id="cwhstock_data", day_of_week='0-6', replace_existing=False,hour=os.environ.get("CWHSTOCK_HOUR"),
              minute=os.environ.get("CWHSTOCK_MINUTE"),
              week='1-53',timezone='UTC')
          jobs.append({'job_id':'cwhstock_data', 'type':'daily'})
          log.info('the cwhstock job added to the scheduler')
      except BaseException as e:
          log.info(e)
          pass
      return json.dumps({'data':jobs})
  </code></pre>
  
  <p>I use this in the flask application, I call the /activatejobs and the jobs are added to the scheduler and it works fine. However when I restart the wsgi server, the jobs aren't started again, I've to remove the .sqlite file and add the jobs again. What I want is the jobs are supposed to be restarted automatically once the scheduler is started (if there are already jobs in the database.) 
  I tried to get such result trying some ways, but couldn't. Any help would be greatly appreciated.  Thanks in Advance. </p>