source: subversion/sites/rails_port/script/cleanup @ 19967

Last change on this file since 19967 was 18530, checked in by tomhughes, 11 years ago

Add exit statement to shut rails up.

  • Property svn:executable set to *
File size: 734 bytes
Line 
1#!/usr/bin/env ruby
2
3require File.dirname(__FILE__) + '/../config/environment'
4
5last_session_id = 0
6
7begin
8  sessions = Session.find(:all,
9                          :conditions => ["updated_at < ? and id > ?", 1.week.ago, last_session_id],
10                          :order => :id, :limit => 1000)
11
12  sessions.each do |session|
13    last_session_id = session.id
14
15    begin
16      if session[:user] and User.find(session[:user])
17        session.destroy if session.updated_at < 1.month.ago
18      else
19        session.destroy
20      end
21    rescue Exception => ex
22      puts "Invalid session #{session.session_id}: #{ex.to_s}"
23      session.destroy
24    end
25  end
26end while sessions.length > 0
27
28UserToken.delete_all("expiry < NOW()")
29
30exit 0
Note: See TracBrowser for help on using the repository browser.