[7375ab]: src / MHiveCore.cpp Maximize Restore History

Download this file

MHiveCore.cpp    83 lines (66 with data), 3.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "org/esb/hive/HiveListener.h"
#include "org/esb/web/WebServer.h"
#include "config.h"
#include "org/esb/io/File.h"
#include "org/esb/lang/CtrlCHitWaiter.h"
#include "org/esb/hive/DatabaseService.h"
#include "org/esb/config/config.h"
#include "org/esb/signal/Messenger.h"
#include "org/esb/signal/Message.h"
#include "org/esb/hive/job/ProcessUnitController.h"
#include "org/esb/hive/ExportScanner.h"
#include "org/esb/hive/CodecFactory.h"
#include "org/esb/hive/NodeResolver.h"
#include "org/esb/av/FormatBaseStream.h"
#include "org/esb/util/Log.h"
int main(int argc, char** argv) {
Log::open("");
/*initialise the config class*/
org::esb::config::Config::init("");
org::esb::hive::Node node;
node.setData("type", "server");
node.setData("version", MHIVE_VERSION);
node.setData("port", org::esb::config::Config::getProperty("client.port", "20200"));
org::esb::hive::NodeResolver res(boost::asio::ip::address::from_string("0.0.0.0"), boost::asio::ip::address::from_string("239.255.0.1"), 6000, node);
res.start();
org::esb::av::FormatBaseStream::initialize();
/**setting internal db url*/
// org::esb::config::Config::setProperty("db.url", "host=localhost;database=hive;user=root;port=3306");
/**starting the internal database service*/
if (!org::esb::hive::DatabaseService::databaseExist()) {
org::esb::hive::DatabaseService::createDatabase();
org::esb::hive::DatabaseService::createTables();
org::esb::hive::DatabaseService::loadPresets();
}
org::esb::hive::DatabaseService::updateTables();
if (!org::esb::config::Config::init("")) {
LOGERROR("could not load config from Database, exiting!!!");
exit(1);
}
org::esb::web::WebServer webserver;
org::esb::signal::Messenger::getInstance().addMessageListener(webserver);
org::esb::hive::job::ProcessUnitController puw;
org::esb::signal::Messenger::getInstance().addMessageListener(puw);
org::esb::hive::ExportScanner expscan;
org::esb::signal::Messenger::getInstance().addMessageListener(expscan);
org::esb::hive::HiveListener hive;
org::esb::signal::Messenger::getInstance().addMessageListener(hive);
org::esb::signal::Messenger::getInstance().sendMessage(org::esb::signal::Message().setProperty("processunitcontroller", org::esb::hive::START));
org::esb::signal::Messenger::getInstance().sendRequest(org::esb::signal::Message().setProperty("webserver", org::esb::hive::START));
org::esb::signal::Messenger::getInstance().sendRequest(org::esb::signal::Message().setProperty("exportscanner", org::esb::hive::START));
org::esb::signal::Messenger::getInstance().sendMessage(org::esb::signal::Message().setProperty("hivelistener", org::esb::hive::START));
org::esb::lang::CtrlCHitWaiter::wait();
LOGINFO("shutdown app, this will take some time!");
/*
*
* Stopping Application Services from configuration
*
*/
org::esb::signal::Messenger::getInstance().sendRequest(org::esb::signal::Message().setProperty("exportscanner", org::esb::hive::STOP));
org::esb::signal::Messenger::getInstance().sendRequest(org::esb::signal::Message().setProperty("processunitcontroller", org::esb::hive::STOP));
org::esb::signal::Messenger::getInstance().sendRequest(org::esb::signal::Message().setProperty("webserver", org::esb::hive::STOP));
org::esb::hive::CodecFactory::free();
org::esb::signal::Messenger::getInstance().sendRequest(org::esb::signal::Message().setProperty("hivelistener", org::esb::hive::STOP));
// org::esb::hive::DatabaseService::stop();
org::esb::signal::Messenger::free();
}