title: How to start a background thread when django server is up?
body: <p><strong>TL;DR</strong> In my django project, where do I put my "start-a-thread" code to make a thread run as soon as the django server is up?</p>
  
  <p>First of all, Happy New Year Everyone! This is a question from a newbie so it might seem dumb. Thank you for your patience and help in advance!</p>
  
  <p><strong>Background Information</strong><br>
  Recently I am writing a MQTT forwarding program which receives MQTT message. I'd like user to set some rules to handle messages to be forwarded so I chose django to build a web server. User can edit the rules themselves on the web page.<br>
  For the MQTT client I need to have a thread to receive MQTT message no matter if the user opens a webpage or not, so I cannot write it in the <em>view.py</em>. If I write a shell to start django server and my script separately, I am not sure how to pass the users settings from django server to my mqtt client script.</p>
  
  <p><strong>Question</strong><br>
  1. Is there a way to start a background thread as soon as I typed <code>python manage.py runserver</code>?<br>
  2. One of the user settings is the MQTT server host, so once the user change this entry on the webpage, the background MQTT client should restart and connect to the new host. Is there any ways to achieve that?</p>
  
  <p>I did some research and some likely solutions I found were <code>django-background-tasks</code> or <code>Celery</code> but I am not sure those are the right way, and I think this problem is too small to import another heavy module to deal with. Please give me some advice! If you are unclear about anything feel free to ask me!<br>
  Thank you again!</p>