4 * @brief Main settingsd source file.
7 * Copyright 2012, 2013 Intel Corporation All Rights Reserved.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation;
12 * version 2.1 of the License.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301 USA
25 #include "../lib/config.hpp"
26 #include "../lib/manager.hpp"
28 #include "configurator.hpp"
29 #include "websocket_server.hpp"
31 #include <settingsd/glib_traits.hpp>
32 #include <settingsd/unique_ptr.hpp>
40 * settingsd program entry point.
42 * @param[in] argc The number of settingsd command line arguments.
43 * @param[in] argv The settingsd command line option/argument vector.
46 main(int argc, char * argv[])
48 std::cerr << PACKAGE_STRING << '\n';
53 settings::configurator config(argc, argv, IVI_SETTINGS_DBUS_NAME);
55 settings::manager manager(config.settings_dir());
57 // The websocket server will run in its own thread.
59 [&config, &manager](){
60 // Exceptions are not propagated to other threads with out
61 // explicit code to do that. Handle exceptions in this
64 // Tie the lifetime of the websocket_server to this thread,
65 // not the main thread, so that we have no lifetime related
66 // race conditions with respect to the underlying
67 // libwebsocket_context object.
68 settings::websocket_server server(config, manager);
71 catch (std::exception & e) {
72 std::cerr << e.what() << '\n';
74 // Probably not something from which we can recover. Just
75 // terminate the daemon.
76 std::exit(EXIT_FAILURE);
80 // Glib related events, including GDbus related signal handlers,
81 // will handled in this (main) thread.
82 settings::unique_ptr<GMainLoop> const loop(g_main_loop_new(nullptr, false));
83 g_main_loop_run(loop.get());
85 catch (std::exception & e) {
86 std::cerr << e.what() << '\n';
97 // indent-tabs-mode: nil