default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / FS / bin / freeside-selfservice-server
old mode 100644 (file)
new mode 100755 (executable)
index 2087e71..4272cae
@@ -1,5 +1,11 @@
 #!/usr/bin/perl -w
 
+=head1 NAME
+
+freeside-selfservice-server
+
+=cut
+
 use strict;
 use vars qw( $FREESIDE_LOG $FREESIDE_LOCK );
 use vars qw( $Debug %kids $kids $max_kids $ssh_pid %old_ssh_pid $keepalives );
@@ -13,11 +19,14 @@ use Storable 2.09 qw(nstore_fd fd_retrieve);
 use Net::SSH qw(sshopen2);
 use FS::Daemon qw(daemonize1 drop_root logfile daemonize2 sigint sigterm);
 use FS::UID qw(adminsuidsetup forksuidsetup);
-use FS::ClientAPI;
+use FS::ClientAPI qw( load_clientapi_modules );
 use FS::ClientAPI_SessionCache;
+use FS::Record qw( qsearch qsearchs );
+use FS::TicketSystem;
 
 use FS::Conf;
 use FS::cust_svc;
+use FS::agent;
 
 $FREESIDE_LOG = "%%%FREESIDE_LOG%%%";
 $FREESIDE_LOCK = "%%%FREESIDE_LOCK%%%";
@@ -50,6 +59,8 @@ drop_root();
 
 $ENV{HOME} = (getpwuid($>))[7]; #for ssh
 
+load_clientapi_modules;
+
 adminsuidsetup $user;
 
 #logfile("/usr/local/etc/freeside/selfservice.". $FS::UID::datasrc); #MACHINE
@@ -58,10 +69,15 @@ logfile("$FREESIDE_LOG/selfservice.$machine.log");
 daemonize2();
 
 my $conf = new FS::Conf;
+my $ticket_system = $conf->config('ticket_system');
 if ( $conf->exists('selfservice-ignore_quantity') ) {
   $FS::cust_svc::ignore_quantity = 1;
   $FS::cust_svc::ignore_quantity = 1; #now it is used twice.
 }
+if ( $conf->exists('selfservice-db_profile') ) {
+  eval "use DBIx::Profile";
+  warn $@ if $@;
+}
 
 #clear the signup info cache so an "/etc/init.d/freeside restart" will pick
 #up new info... (better as a callback in Signup.pm?)
@@ -70,6 +86,13 @@ my $cache = new FS::ClientAPI_SessionCache( {
 } );
 $cache->remove('signup_info_cache');
 
+#and also clear the selfservice skin info cache, for the same reason
+my $ss_cache = new FS::ClientAPI_SessionCache( {
+  'namespace' => 'FS::ClientAPI::MyAccount',
+} );
+$ss_cache->remove($_)
+  foreach grep /^skin_info_cache_agent/, $ss_cache->get_keys();
+
 my $clientd = "/usr/local/sbin/freeside-selfservice-clientd"; #better name?
 
 my $warnkids=0;
@@ -146,12 +169,10 @@ while (1) {
       warn "child $pid spawned\n" if $Debug;
     } else { #kid time
 
-      ##get new db handle
       $FS::UID::dbh->{InactiveDestroy} = 1;
       forksuidsetup($user);
 
-      #get db handle
-      #adminsuidsetup($user);
+      FS::TicketSystem->init() if $ticket_system;
 
       my $type = $packet->{_packet};
       warn "calling $type handler\n" if $Debug;