Rev 1651 | Rev 1656 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1651 | Rev 1652 | ||
|---|---|---|---|
| Line 22... | Line 22... | ||
| 22 | 22 | ||
| 23 | #include <boost/program_options.hpp> |
23 | #include <boost/program_options.hpp> |
| 24 | #include <boost/thread/mutex.hpp> |
24 | #include <boost/thread/mutex.hpp> |
| 25 | #include <boost/thread/condition.hpp> |
25 | #include <boost/thread/condition.hpp> |
| 26 | #include <boost/thread/locks.hpp> |
26 | #include <boost/thread/locks.hpp> |
| - | 27 | ||
| - | 28 | #include "config.h" |
|
| 27 | 29 | ||
| 28 | #include "logging/Logger.h" |
30 | #include "logging/Logger.h" |
| 29 | #include "net/Manager.h" |
31 | #include "net/Manager.h" |
| 30 | #include "timer/Manager.h" |
32 | #include "timer/Manager.h" |
| 31 | #include "config/Manager.h" |
33 | #include "config/Manager.h" |
| Line 40... | Line 42... | ||
| 40 | #include "vm/plugin/System.h" |
42 | #include "vm/plugin/System.h" |
| 41 | #include "vm/plugin/Timer.h" |
43 | #include "vm/plugin/Timer.h" |
| 42 | #include "vm/plugin/Module.h" |
44 | #include "vm/plugin/Module.h" |
| 43 | #include "vm/plugin/Console.h" |
45 | #include "vm/plugin/Console.h" |
| 44 | #include "vm/plugin/Storage.h" |
46 | #include "vm/plugin/Storage.h" |
| - | 47 | ||
| - | 48 | #ifdef USE_PLUGIN_XORG |
|
| 45 | #include "vm/plugin/Xorg.h" |
49 | #include "vm/plugin/Xorg.h" |
| - | 50 | #endif // USE_PLUGIN_XORG |
|
| - | 51 | ||
| 46 | #include "vm/plugin/Socket.h" |
52 | #include "vm/plugin/Socket.h" |
| 47 | 53 | ||
| 48 | using namespace atom; |
54 | using namespace atom; |
| 49 | 55 | ||
| 50 | logging::Logger LOG("Main"); |
56 | logging::Logger LOG("Main"); |
| Line 55... | Line 61... | ||
| 55 | void Handler(int status); |
61 | void Handler(int status); |
| 56 | void CleanUp(); |
62 | void CleanUp(); |
| 57 | 63 | ||
| 58 | int main(int argc, char **argv) |
64 | int main(int argc, char **argv) |
| 59 | { |
65 | { |
| 60 | LOG.Info("Atom Daemon, version |
66 | LOG.Info("Atom Daemon, version " + std::string(VERSION) + " starting..."); |
| 61 | LOG.Info("Written by Mattias Runge 2010."); |
67 | LOG.Info("Written by Mattias Runge 2010."); |
| 62 | LOG.Info("Released under GPL version 2."); |
68 | LOG.Info("Released under GPL version 2."); |
| 63 | 69 | ||
| 64 | signal(SIGTERM, Handler); |
70 | signal(SIGTERM, Handler); |
| 65 | signal(SIGINT, Handler); |
71 | signal(SIGINT, Handler); |
| Line 71... | Line 77... | ||
| 71 | 77 | ||
| 72 | if (!config::Manager::Instance()->Set(argc, argv)) |
78 | if (!config::Manager::Instance()->Set(argc, argv)) |
| 73 | { |
79 | { |
| 74 | CleanUp(); |
80 | CleanUp(); |
| 75 | return EXIT_SUCCESS; |
81 | return EXIT_SUCCESS; |
| 76 | } |
82 | } |
| 77 | 83 | ||
| 78 | if (config::Manager::Instance()->Exist("LogFile")) |
84 | if (config::Manager::Instance()->Exist("LogFile")) |
| 79 | { |
85 | { |
| 80 | logging::Logger::OpenFile(config::Manager::Instance()->GetAsString("LogFile")); |
86 | logging::Logger::OpenFile(config::Manager::Instance()->GetAsString("LogFile")); |
| 81 | } |
87 | } |
| 82 | 88 | ||
| Line 121... | Line 127... | ||
| 121 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::System(vm::Manager::Instance()->GetIoService()))); |
127 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::System(vm::Manager::Instance()->GetIoService()))); |
| 122 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Console(vm::Manager::Instance()->GetIoService(), config::Manager::Instance()->GetAsInt("CommandPort")))); |
128 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Console(vm::Manager::Instance()->GetIoService(), config::Manager::Instance()->GetAsInt("CommandPort")))); |
| 123 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Storage(vm::Manager::Instance()->GetIoService()))); |
129 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Storage(vm::Manager::Instance()->GetIoService()))); |
| 124 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Timer(vm::Manager::Instance()->GetIoService()))); |
130 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Timer(vm::Manager::Instance()->GetIoService()))); |
| 125 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Module(vm::Manager::Instance()->GetIoService()))); |
131 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Module(vm::Manager::Instance()->GetIoService()))); |
| - | 132 | ||
| - | 133 | #ifdef USE_PLUGIN_XORG |
|
| 126 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Xorg(vm::Manager::Instance()->GetIoService()))); |
134 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Xorg(vm::Manager::Instance()->GetIoService()))); |
| - | 135 | #endif // USE_PLUGIN_XORG |
|
| - | 136 | ||
| 127 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Socket(vm::Manager::Instance()->GetIoService()))); |
137 | vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Socket(vm::Manager::Instance()->GetIoService()))); |
| 128 | 138 | ||
| 129 | 139 | ||
| 130 | vm::Manager::Instance()->Start(config::Manager::Instance()->GetAsString("ScriptPath")); |
140 | vm::Manager::Instance()->Start(config::Manager::Instance()->GetAsString("ScriptPath")); |
| 131 | 141 | ||