#!/usr/bin/perl
use threads;
+use threads::shared;
use strict;
use warnings;
use HTTP::Daemon;
}
log_info("HTTP daemon started with URL " . $daemon->url);
print "Web server started with URL: " . $daemon->url, "\n";
+my $running :shared;
+$running = 1;
my $data_collector_handle = threads->create('data_collector_thread');
while (my $connection = $daemon->accept) {
REQUEST:
}
log_info("Shutting down web server");
$daemon->close();
+$running = 0;
Varnish::DB->finish();
log_info("Stopping data collector thread");
$data_collector_handle->join();
sleep 1; # wait for the server to come up
while (1) {
my $user_agent = LWP::UserAgent->new;
+
$user_agent->timeout(10);
my $response = $user_agent->get($url);
-
- last if ($response->code eq "500");
sleep($interval);
+
+ last if (!$running);
}
print "Data collector thread stopped.\n";
}