mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-07 07:40:56 +08:00
Added exception handling around Beanstalk
This commit is contained in:
@@ -274,7 +274,8 @@ void streamRecognitionThread(void* arg)
|
||||
|
||||
bool writeToQueue(std::string jsonResult)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
Beanstalk::Client client(BEANSTALK_QUEUE_HOST, BEANSTALK_PORT);
|
||||
client.use(BEANSTALK_TUBE_NAME);
|
||||
|
||||
@@ -288,6 +289,11 @@ bool writeToQueue(std::string jsonResult)
|
||||
|
||||
LOG4CPLUS_INFO(logger, "put job id: " << id );
|
||||
|
||||
}
|
||||
catch (const std::runtime_error& error)
|
||||
{
|
||||
LOG4CPLUS_WARN(logger, "Error writing to Beanstalk. Result has not been saved.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -302,12 +308,18 @@ void dataUploadThread(void* arg)
|
||||
|
||||
UploadThreadData* udata = (UploadThreadData*) arg;
|
||||
|
||||
Beanstalk::Client client(BEANSTALK_QUEUE_HOST, BEANSTALK_PORT);
|
||||
|
||||
|
||||
|
||||
while(daemon_active)
|
||||
{
|
||||
try
|
||||
{
|
||||
Beanstalk::Client client(BEANSTALK_QUEUE_HOST, BEANSTALK_PORT);
|
||||
|
||||
client.watch(BEANSTALK_TUBE_NAME);
|
||||
|
||||
while(daemon_active)
|
||||
while (daemon_active)
|
||||
{
|
||||
Beanstalk::Job job;
|
||||
|
||||
@@ -328,9 +340,19 @@ void dataUploadThread(void* arg)
|
||||
}
|
||||
}
|
||||
|
||||
// Wait 10ms
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
}
|
||||
catch (const std::runtime_error& error)
|
||||
{
|
||||
LOG4CPLUS_WARN(logger, "Error connecting to Beanstalk. Will retry." );
|
||||
}
|
||||
// wait 5 seconds
|
||||
usleep(5000000);
|
||||
}
|
||||
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user