#include <unordered_map>
#include "db/database.h"
-#include "db/mysql.h"
+#include "db/psql.h"
#include "crypto/simpleOpensslSigner.h"
#include "crypto/remoteSigner.h"
#include "crypto/sslUtil.h"
int main( int argc, const char* argv[] ) {
bool once = false;
+ bool resetOnly = false;
if( argc == 2 && std::string( "--once" ) == argv[1] ) {
once = true;
}
+ if( argc == 2 && std::string( "--reset" ) == argv[1] ) {
+ resetOnly = true;
+ }
std::string path;
logger::fatal( "Error: no serial device is given!" );
return -1;
}
-
- std::shared_ptr<JobProvider> jp( new MySQLJobProvider( sqlHost, sqlUser, sqlPass, sqlDB ) );
+ std::shared_ptr<JobProvider> jp = std::make_shared<PostgresJobProvider>( sqlHost, sqlUser, sqlPass, sqlDB );
std::shared_ptr<BIO> b = openSerial( serialPath );
std::shared_ptr<BIO> slip1( BIO_new( toBio<SlipBIO>() ), BIO_free );
- static_cast<SlipBIO*>( slip1->ptr )->setTarget( std::shared_ptr<OpensslBIO>( new OpensslBIOWrapper( b ) ) );
- std::shared_ptr<RemoteSigner> sign( new RemoteSigner( slip1, generateSSLContext( false ) ) );
+ static_cast<SlipBIO*>( slip1->ptr )->setTarget( std::make_shared<OpensslBIOWrapper>( b ), false );
+ auto sign = std::make_shared<RemoteSigner>( slip1, generateSSLContext( false ) );
// std::shared_ptr<Signer> sign( new SimpleOpensslSigner() );
+ if( resetOnly ) {
+ std::cout << "Doing BIO reset" << std::endl;
+ int result = BIO_reset( slip1.get() );
+ std::cout << "Did BIO reset, result " << result << ", exiting." << std::endl;
+ return result;
+ }
+
time_t lastCRLCheck = 0;
while( true ) {
lastCRLCheck = current;
}
- std::shared_ptr<Job> job = jp->fetchJob();
-
+ std::shared_ptr<Job> job;
+ try {
+ job = jp->fetchJob();
+ } catch ( std::exception &e ){
+ logger::errorf ( "Exception while fetchJob: %s", e.what() );
+ }
if( !job ) {
logger::note( "Nothing to work on." );
sleep( 5 );