OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 #include <tr1/memory> | 6 #include <tr1/memory> |
7 #include <vector> | 7 #include <vector> |
8 #include <gflags/gflags.h> | 8 #include <gflags/gflags.h> |
9 #include <glib.h> | 9 #include <glib.h> |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "chromeos/obsolete_logging.h" | 11 #include "chromeos/obsolete_logging.h" |
12 #include "update_engine/dbus_constants.h" | 12 #include "update_engine/dbus_constants.h" |
13 #include "update_engine/dbus_service.h" | 13 #include "update_engine/dbus_service.h" |
14 #include "update_engine/update_attempter.h" | 14 #include "update_engine/update_attempter.h" |
15 | 15 |
16 extern "C" { | 16 extern "C" { |
17 #include "update_engine/update_engine.dbusserver.h" | 17 #include "update_engine/update_engine.dbusserver.h" |
18 } | 18 } |
19 | 19 |
20 DEFINE_bool(logtostderr, false, | 20 DEFINE_bool(logtostderr, false, |
21 "Write logs to stderr instead of to a file in log_dir."); | 21 "Write logs to stderr instead of to a file in log_dir."); |
22 DEFINE_bool(forground, false, | |
Chris Masone
2010/05/10 22:46:52
foreground
| |
23 "Don't daemon()ize; run in forground."); | |
22 | 24 |
23 using std::string; | 25 using std::string; |
24 using std::tr1::shared_ptr; | 26 using std::tr1::shared_ptr; |
25 using std::vector; | 27 using std::vector; |
26 | 28 |
27 namespace chromeos_update_engine { | 29 namespace chromeos_update_engine { |
28 | 30 |
29 namespace { | 31 namespace { |
30 | 32 |
31 struct PeriodicallyUpdateArgs { | 33 struct PeriodicallyUpdateArgs { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 dbus_g_thread_init(); | 87 dbus_g_thread_init(); |
86 chromeos_update_engine::Subprocess::Init(); | 88 chromeos_update_engine::Subprocess::Init(); |
87 google::ParseCommandLineFlags(&argc, &argv, true); | 89 google::ParseCommandLineFlags(&argc, &argv, true); |
88 CommandLine::Init(argc, argv); | 90 CommandLine::Init(argc, argv); |
89 logging::InitLogging("/var/log/update_engine.log", | 91 logging::InitLogging("/var/log/update_engine.log", |
90 (FLAGS_logtostderr ? | 92 (FLAGS_logtostderr ? |
91 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG : | 93 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG : |
92 logging::LOG_ONLY_TO_FILE), | 94 logging::LOG_ONLY_TO_FILE), |
93 logging::DONT_LOCK_LOG_FILE, | 95 logging::DONT_LOCK_LOG_FILE, |
94 logging::APPEND_TO_OLD_LOG_FILE); | 96 logging::APPEND_TO_OLD_LOG_FILE); |
97 if (!FLAGS_forground) | |
Chris Masone
2010/05/10 22:46:52
foreground
| |
98 PLOG_IF(FATAL, daemon(0, 0) == 1) << "daemon() failed"; | |
99 | |
95 LOG(INFO) << "Chrome OS Update Engine starting"; | 100 LOG(INFO) << "Chrome OS Update Engine starting"; |
96 | 101 |
97 // Create the single GMainLoop | 102 // Create the single GMainLoop |
98 GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE); | 103 GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE); |
99 | 104 |
100 // Create the update attempter: | 105 // Create the update attempter: |
101 chromeos_update_engine::UpdateAttempter update_attempter; | 106 chromeos_update_engine::UpdateAttempter update_attempter; |
102 | 107 |
103 // Create the dbus service object: | 108 // Create the dbus service object: |
104 dbus_g_object_type_install_info(UPDATE_ENGINE_TYPE_SERVICE, | 109 dbus_g_object_type_install_info(UPDATE_ENGINE_TYPE_SERVICE, |
(...skipping 22 matching lines...) Expand all Loading... | |
127 g_main_loop_run(loop); | 132 g_main_loop_run(loop); |
128 | 133 |
129 // Cleanup: | 134 // Cleanup: |
130 g_main_loop_unref(loop); | 135 g_main_loop_unref(loop); |
131 update_attempter.set_dbus_service(NULL); | 136 update_attempter.set_dbus_service(NULL); |
132 g_object_unref(G_OBJECT(service)); | 137 g_object_unref(G_OBJECT(service)); |
133 | 138 |
134 LOG(INFO) << "Chrome OS Update Engine terminating"; | 139 LOG(INFO) << "Chrome OS Update Engine terminating"; |
135 return 0; | 140 return 0; |
136 } | 141 } |
OLD | NEW |