Clear all session of Django webapp on server restart

Viewed 481

I am facing problem with below scenario, where I need to clear all sessions on my django app with conditions applied.

  1. Cannot use cron
  2. Webapp's javascript is requesting server api per minute for health check wether server is active or not
  3. Upon sever status off webapp is automatically logging out and clearing the current user's session.
  4. Problem is I want to clear all users session
  5. There can be situation like only one user is logged in, others session are active but not on web browser( means they have recently closed the tab)
  6. Other situation is only one session is there but its idle ( closed tab)

Now how can I thrash all sessions

Two things I came up with is

  1. Read Last PID and store it in db, whenever any user hits url, it will cross check the PID and clear all sessions if PID mismatch occurs ( Not sure as PID can be same after restart)
  2. Server restart event should be listened and kill all sessions ( Not sure how to implement, SIGHUP kind of events)

Project Architecture:

  • Linux
  • Python2.7 (Django)
  • Nginx

Any other suggestions please.

0 Answers
Related