Rev 1940 | Rev 1947 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1940 | Rev 1945 | ||
|---|---|---|---|
| Line 51... | Line 51... | ||
| 51 | 51 | ||
| 52 | #ifdef USE_PLUGIN_XORG |
52 | #ifdef USE_PLUGIN_XORG |
| 53 | #include "vm/plugin/Xorg.h" |
53 | #include "vm/plugin/Xorg.h" |
| 54 | #endif // USE_PLUGIN_XORG |
54 | #endif // USE_PLUGIN_XORG |
| 55 | 55 | ||
| - | 56 | #ifdef USE_PLUGIN_MYSQL |
|
| - | 57 | #include "vm/plugin/MySql.h" |
|
| - | 58 | #endif // USE_PLUGIN_MYSQL |
|
| - | 59 | ||
| 56 | using namespace atom; |
60 | using namespace atom; |
| 57 | 61 | ||
| 58 | logging::Logger LOG ("Main"); |
62 | logging::Logger LOG("Main"); |
| 59 | std::vector<broker::Subscriber::Pointer> subscribers; |
63 | std::vector<broker::Subscriber::Pointer> subscribers; |
| 60 | boost::condition on_message_condition; |
64 | boost::condition on_message_condition; |
| 61 | boost::mutex guard_mutex; |
65 | boost::mutex guard_mutex; |
| 62 | 66 | ||
| 63 | void Handler (int status); |
67 | void Handler(int status); |
| 64 | void CleanUp(); |
68 | void CleanUp(); |
| 65 | 69 | ||
| 66 | int main (int argc, char **argv) |
70 | int main(int argc, char **argv) |
| 67 | { |
71 | { |
| 68 | LOG.Info ("\033[29;1mAtom Daemon, version " + std::string (VERSION) + " starting...\033[0m"); |
72 | LOG.Info("\033[29;1mAtom Daemon, version " + std::string(VERSION) + " starting...\033[0m"); |
| 69 | LOG.Info ("\033[29;1mReleased under " + std::string (LICENSE) + ".\033[0m"); |
73 | LOG.Info("\033[29;1mReleased under " + std::string(LICENSE) + ".\033[0m"); |
| 70 | LOG.Info ("Written by Mattias Runge 2010-2012."); |
74 | LOG.Info("Written by Mattias Runge 2010-2012."); |
| 71 | 75 | ||
| 72 | signal (SIGTERM, Handler); |
76 | signal(SIGTERM, Handler); |
| Line 74... | Line 78... | ||
| 74 | signal (SIGQUIT, Handler); |
78 | signal(SIGQUIT, Handler); |
| 75 | signal (SIGABRT, Handler); |
79 | signal(SIGABRT, Handler); |
| 76 | signal (SIGPIPE, Handler); |
80 | signal(SIGPIPE, Handler); |
| 77 | 81 | ||
| 78 | config::Manager::Create(); |
82 | config::Manager::Create(); |
| 79 | 83 | ||
| 80 | if (!config::Manager::Instance()->Set (argc, argv)) |
84 | if (!config::Manager::Instance()->Set(argc, argv)) |
| 81 | { |
85 | { |
| 82 | CleanUp(); |
86 | CleanUp(); |
| 83 | return EXIT_SUCCESS; |
87 | return EXIT_SUCCESS; |
| 84 | } |
88 | } |
| Line 122... | Line 126... | ||
| 122 | } |
126 | } |
| 123 | 127 | ||
| 124 | storage::Manager::Instance()->SetRootPath (config::Manager::Instance()->GetAsString ("StoragePath")); |
128 | storage::Manager::Instance()->SetRootPath(config::Manager::Instance()->GetAsString("StoragePath")); |
| 125 | 129 | ||
| 126 | can::Protocol::Instance()->Load (config::Manager::Instance()->GetAsString ("ProtocolFile")); |
130 | can::Protocol::Instance()->Load(config::Manager::Instance()->GetAsString("ProtocolFile")); |
| 127 | 131 | ||
| 128 | if (config::Manager::Instance()->Exist ("MonitorPort")) |
132 | if (config::Manager::Instance()->Exist("MonitorPort")) |
| 129 | { |
133 | { |
| 130 | subscribers.push_back (can::Monitor::Pointer (new can::Monitor (config::Manager::Instance()->GetAsInt ("MonitorPort")))); |
134 | subscribers.push_back(can::Monitor::Pointer(new can::Monitor(config::Manager::Instance()->GetAsInt("MonitorPort")))); |
| 131 | } |
135 | } |
| 132 | 136 | ||
| 133 | if (config::Manager::Instance()->Exist ("DaemonPort")) |
137 | if (config::Manager::Instance()->Exist("DaemonPort")) |
| 134 | { |
138 | { |
| 135 | subscribers.push_back (can::CanDaemon::Pointer (new can::CanDaemon (config::Manager::Instance()->GetAsInt ("DaemonPort")))); |
139 | subscribers.push_back(can::CanDaemon::Pointer(new can::CanDaemon(config::Manager::Instance()->GetAsInt("DaemonPort")))); |
| 136 | } |
140 | } |
| 137 | 141 | ||
| 138 | subscribers.push_back (control::Manager::Instance()); |
142 | subscribers.push_back(control::Manager::Instance()); |
| 139 | 143 | ||
| 140 | vm::Manager::Instance()->AddPlugin (vm::Plugin::Pointer (new vm::plugin::System (vm::Manager::Instance()->GetIoService()))); |
144 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::System(vm::Manager::Instance()->GetIoService()))); |
| 141 | vm::Manager::Instance()->AddPlugin (vm::Plugin::Pointer (new vm::plugin::Console (vm::Manager::Instance()->GetIoService(), config::Manager::Instance()->GetAsInt ("CommandPort")))); |
145 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Console(vm::Manager::Instance()->GetIoService(), config::Manager::Instance()->GetAsInt("CommandPort")))); |
| 142 | vm::Manager::Instance()->AddPlugin (vm::Plugin::Pointer (new vm::plugin::Storage (vm::Manager::Instance()->GetIoService()))); |
146 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Storage(vm::Manager::Instance()->GetIoService()))); |
| 143 | vm::Manager::Instance()->AddPlugin (vm::Plugin::Pointer (new vm::plugin::Timer (vm::Manager::Instance()->GetIoService()))); |
147 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Timer(vm::Manager::Instance()->GetIoService()))); |
| 144 | vm::Manager::Instance()->AddPlugin (vm::Plugin::Pointer (new vm::plugin::Module (vm::Manager::Instance()->GetIoService()))); |
148 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Module(vm::Manager::Instance()->GetIoService()))); |
| Line 146... | Line 150... | ||
| 146 | vm::Manager::Instance()->AddPlugin (vm::Plugin::Pointer (new vm::plugin::Socket (vm::Manager::Instance()->GetIoService()))); |
150 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Socket(vm::Manager::Instance()->GetIoService()))); |
| 147 | 151 | ||
| 148 | #ifdef USE_PLUGIN_XORG |
152 | #ifdef USE_PLUGIN_XORG |
| 149 | vm::Manager::Instance()->AddPlugin (vm::Plugin::Pointer (new vm::plugin::Xorg (vm::Manager::Instance()->GetIoService()))); |
153 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Xorg(vm::Manager::Instance()->GetIoService()))); |
| 150 | #endif // USE_PLUGIN_XORG |
154 | #endif // USE_PLUGIN_XORG |
| - | 155 | ||
| - | 156 | #ifdef USE_PLUGIN_MYSQL |
|
| - | 157 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::MySql(vm::Manager::Instance()->GetIoService()))); |
|
| - | 158 | #endif // USE_PLUGIN_MYSQL |
|
| 151 | 159 | ||
| 152 | vm::Manager::Instance()->Start (config::Manager::Instance()->GetAsString ("ScriptPath"), config::Manager::Instance()->GetAsString ("UserScriptPath")); |
160 | vm::Manager::Instance()->Start(config::Manager::Instance()->GetAsString("ScriptPath"), config::Manager::Instance()->GetAsString("UserScriptPath")); |
| 153 | 161 | ||
| 154 | if (config::Manager::Instance()->Exist ("CanNet")) |
162 | if (config::Manager::Instance()->Exist("CanNet")) |
| 155 | { |
163 | { |