Hi Julien, You can create another background process with it's own settings using WSGIStartupScript and a separate WSGIProcessGroup with 1 process and 1 thread.
However it seems odd that you would do this on startup and put it in a database. Why does it need done on each startup if it is in the DB? Perhaps just create another table in the db with a status: empty, scanning, filled. On a timed interval or startup you could basic locking to lock that table, and only one process/thread would get to do.the work. J On Apr 25, 2016 9:13 AM, "Julien Delafontaine" <[email protected]> wrote: > Hi again, > > It seems trememdously hard in Django to run code only once when the app > starts, instead it is executed once per process. I tried wsgi.py, > settings.py, apps.py, and many others. Is it a good idea to use the > --service-script option for that purpose? > > I want to scan a folder when the app starts to update my database > according to the files found there. > Like > --service-script scan myapp/scripts/scan_folders.py > even if I don't use the service anymore after that. > > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/modwsgi. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/modwsgi. For more options, visit https://groups.google.com/d/optout.
