Add a new setting to expire persistent rooms

Using a dedicated timeout, so you can set it very high, but still remove very old rooms
Fix #28
master
Daniel Berteaud 11 years ago
parent 883905af6a
commit 6517fb930a
  1. 6
      conf/vroom.conf.sample
  2. 34
      public/vroom.pl

@ -20,8 +20,12 @@ template => 'default',
secret => 'ChangeMe!', secret => 'ChangeMe!',
# App # App
# Rooms without any activity for that long will be destroyed # Rooms without any activity for that long (in seconds) will be destroyed
inactivityTimeout => 3600, inactivityTimeout => 3600,
# Inactivity timeout (in seconds) for persistent rooms
# 0 means they are not deleted. You can use a high number
# so that persistent rooms are kept long enough, but deleted when not used
persistentInactivityTimeout => 0,
logLevel => 'info', logLevel => 'info',
# ID of the Chrome extension for screen sharing # ID of the Chrome extension for screen sharing

@ -62,19 +62,20 @@ app->log->level('info');
our $config = plugin Config => { our $config = plugin Config => {
file => '../conf/vroom.conf', file => '../conf/vroom.conf',
default => { default => {
dbi => 'DBI:mysql:database=vroom;host=localhost', dbi => 'DBI:mysql:database=vroom;host=localhost',
dbUser => 'vroom', dbUser => 'vroom',
dbPassword => 'vroom', dbPassword => 'vroom',
signalingServer => 'https://vroom.example.com/', signalingServer => 'https://vroom.example.com/',
stunServer => 'stun.l.google.com:19302', stunServer => 'stun.l.google.com:19302',
realm => 'vroom', realm => 'vroom',
emailFrom => 'vroom@example.com', emailFrom => 'vroom@example.com',
feedbackRecipient => 'admin@example.com', feedbackRecipient => 'admin@example.com',
template => 'default', template => 'default',
inactivityTimeout => 3600, inactivityTimeout => 3600,
logLevel => 'info', persistentInactivityTimeout => 0,
chromeExtensionId => 'ecicdpoejfllflombfanbhfpgcimjddn', logLevel => 'info',
sendmail => '/sbin/sendmail' chromeExtensionId => 'ecicdpoejfllflombfanbhfpgcimjddn',
sendmail => '/sbin/sendmail'
} }
}; };
@ -193,6 +194,13 @@ helper delete_rooms => sub {
$self->db->do("DELETE FROM participants WHERE id IN (SELECT id FROM rooms WHERE activity_timestamp < $timeout AND persistent='0');"); $self->db->do("DELETE FROM participants WHERE id IN (SELECT id FROM rooms WHERE activity_timestamp < $timeout AND persistent='0');");
$self->db->do("DELETE FROM rooms WHERE activity_timestamp < $timeout AND persistent='0';"); $self->db->do("DELETE FROM rooms WHERE activity_timestamp < $timeout AND persistent='0';");
} || return undef; } || return undef;
if ($config->{persistentInactivityTimeout} && $config->{persistentInactivityTimeout} > 0){
eval {
my $timeout = time()-$config->{persistentInactivityTimeout};
$self->db->do("DELETE FROM participants WHERE id IN (SELECT id FROM rooms WHERE activity_timestamp < $timeout AND persistent='1');");
$self->db->do("DELETE FROM rooms WHERE activity_timestamp < $timeout AND persistent='1';");
} || return undef;
}
return 1; return 1;
}; };

Loading…
Cancel
Save