1 package SL::Controller::TaskServer;
5 use parent qw(SL::Controller::Base);
8 use SL::Locale::String qw(t8);
9 use SL::System::TaskServer;
11 use Rose::Object::MakeMethods::Generic
13 'scalar --get_set_init' => [ qw(task_server) ],
16 __PACKAGE__->run_before('check_auth');
25 $::request->{layout}->use_stylesheet('background_jobs.css');
27 flash('warning', $::locale->text('The task server does not appear to be running.')) if !$self->task_server->is_running;
29 $self->setup_show_action_bar;
30 $self->render('task_server/show',
31 title => $::locale->text('Task server status'),
32 last_command_output => $::auth->get_session_value('TaskServer::last_command_output'));
38 if ($self->task_server->is_running) {
39 flash_later('error', $::locale->text('The task server is already running.'));
42 if ($self->task_server->start) {
43 flash_later('info', $::locale->text('The task server was started successfully.'));
45 flash_later('error', $::locale->text('Starting the task server failed.'));
48 $::auth->set_session_value('TaskServer::last_command_output' => $self->task_server->last_command_output);
51 $self->redirect_to(action => 'show');
57 if (!$self->task_server->is_running) {
58 flash_later('error', $::locale->text('The task server is not running.'));
61 if ($self->task_server->stop) {
62 flash_later('info', $::locale->text('The task server was stopped successfully.'));
64 flash_later('error', $::locale->text('Stopping the task server failed. Output:'));
67 $::auth->set_session_value('TaskServer::last_command_output' => $self->task_server->last_command_output);
70 $self->redirect_to(action => 'show');
78 $::auth->assert('admin');
85 sub init_task_server {
86 return SL::System::TaskServer->new;
89 sub setup_show_action_bar {
92 for my $bar ($::request->layout->get('actionbar')) {
95 $self->task_server->is_running ? t8('Stop (verb)') : t8('Start (verb)'),
96 submit => [ '#form' ],
101 link => $self->url_for(controller => 'BackgroundJob', action => 'list'),
105 link => $self->url_for(controller => 'BackgroundJobHistory', action => 'list'),