Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 58c87e38

Von Moritz Bunkus vor mehr als 9 Jahren hinzugefügt

  • ID 58c87e38fbfeec4e1453fd704754419a9a8d2688
  • Vorgänger 4f3a0ab5
  • Nachfolger 428bfc18

Task-Server: Initialisierung vereinheitlicht

Unterschiede anzeigen:

scripts/task_server.pl
51 51
  $::lxdebug->message(0, @_);
52 52
}
53 53

  
54
sub lxinit {
54
sub initialize_kivitendo {
55
  chdir $exe_dir;
56

  
55 57
  my $login  = $lx_office_conf{task_server}->{login};
56 58
  my $client = $lx_office_conf{task_server}->{client};
57 59

  
58 60
  package main;
59 61

  
62
  Form::disconnect_standard_dbh;
60 63
  $::lxdebug       = LXDebug->new;
61 64
  $::locale        = Locale->new($::lx_office_conf{system}->{language});
62 65
  $::form          = Form->new;
63 66
  $::auth          = SL::Auth->new;
64 67
  die "No client configured or no client found with the name/ID '$client'" unless $::auth->set_client($client);
65 68
  $::instance_conf = SL::InstanceConfiguration->new;
66
  $::request       = { cgi => CGI->new({}) };
67

  
68
  die 'cannot reach auth db'               unless $::auth->session_tables_present;
69

  
70
  $::auth->restore_session;
71

  
72
  require "bin/mozilla/common.pl";
73

  
74
  die "cannot find user $login"            unless %::myconfig = $::auth->read_user(login => $login);
75
  die "cannot find locale for user $login" unless $::locale   = Locale->new('de');
76
}
77

  
78
sub per_job_initialization {
79
  $::locale        = Locale->new($::myconfig{countrycode} || $::lx_office_conf{system}->{language});
80
  $::form          = Form->new;
81
  $::instance_conf = SL::InstanceConfiguration->new;
82 69
  $::request       = SL::Request->new(
83 70
    cgi            => CGI->new({}),
84 71
    layout         => SL::Layout::None->new,
85 72
  );
86 73

  
74
  die 'cannot reach auth db'               unless $::auth->session_tables_present;
75

  
87 76
  $::auth->restore_session;
77
  $::auth->create_or_refresh_session;
88 78

  
89
  $::instance_conf->init;
79
  die "cannot find user $login"            unless %::myconfig = $::auth->read_user(login => $login);
80
  die "cannot find locale for user $login" unless $::locale   = Locale->new($::myconfig{countrycode} || $::lx_office_conf{system}->{language});
90 81

  
91 82
  $::form->{__ERROR_HANDLER} = sub { die @_ };
92 83
}
......
173 164
  die "Missing key 'client' in section [task_server] in config file" unless $lx_office_conf{task_server}->{client};
174 165

  
175 166
  drop_privileges();
176
  lxinit();
167
  initialize_kivitendo();
177 168

  
178 169
  return ();
179 170
}
......
181 172
sub gd_run {
182 173
  while (1) {
183 174
    my $ok = eval {
175
      initialize_kivitendo();
176

  
184 177
      debug("Retrieving jobs");
185 178

  
186 179
      my $jobs = SL::DB::Manager::BackgroundJob->get_all_need_to_run;
......
190 183
      foreach my $job (@{ $jobs }) {
191 184
        # Provide fresh global variables in case legacy code modifies
192 185
        # them somehow.
193
        per_job_initialization();
194

  
195
        chdir $exe_dir;
186
        initialize_kivitendo();
196 187

  
197 188
        my $history = $job->run;
198 189

  

Auch abrufbar als: Unified diff