#!/usr/bin/env /Applications/Server.app/Contents/ServerRoot/usr/bin/ruby


##
# Copyright (c) 2009-2014 Apple Inc. All Rights Reserved.
#
# IMPORTANT NOTE: This file is licensed only for use on Apple-branded
# computers and is subject to the terms and conditions of the Apple Software
# License Agreement accompanying the package this file is a part of.
# You may not port this file to another platform without Apple's written consent.
#
# IMPORTANT NOTE: This file is licensed only for use with the Wiki Server feature
# of the Apple Software and is subject to the terms and conditions of the Apple
# Software License Agreement accompanying the package this file is part of.
##

ENV["BUNDLE_GEMFILE"] = "/Applications/Server.app/Contents/ServerRoot/usr/share/collabd/gems/Gemfile"

require 'rubygems'
require 'bundler/setup'
require 'pg'

begin
  con = PGconn.connect(:dbname => 'postgres', :user => '_teamsserver', :host => '/Library/Server/Wiki/PostgresSocket')
  conn.exec("DELETE FROM session WHERE expire_time <= now()")
  conn.exec("VACUUM ANALYZE session")
rescue Exception => e
  # do nothing now, just be quiet
end
