title: How to call a function every time Django restarts?
body: <p>I have a Django webservice that is hosted using Gunicorn in production. I need to call the function <code>restart_event</code> every time the webservice is restarted. This is the pseudo code of the function</p>
  <pre><code>def restart_event():
      &quot;&quot;&quot;This function should be called everytime Django restarts&quot;&quot;&quot;
  
      # read list of registered companies from the database
      companies = Company.objects.all()
  
      for company in companies:
          # perform various operations on the data
          business_logic1(company)
          business_logic2(company)
          change_celery_settings()
  </code></pre>
  <p>How do configure Django such that the above function is called every time Django restarts? Note that since Gunicorn is being used I won't be doing a <code>python manage.py runserver</code> rather I will be starting and stopping the Gunicorn webserver</p>