OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium 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 <signal.h> | 5 #include <signal.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #ifndef _WIN32 | 7 #ifndef _WIN32 |
8 #include <sys/time.h> | 8 #include <sys/time.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <sys/wait.h> | 10 #include <sys/wait.h> |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 #if OS_POSIX | 93 #if OS_POSIX |
94 signal(SIGPIPE, SIG_IGN); | 94 signal(SIGPIPE, SIG_IGN); |
95 signal(SIGCHLD, &signal_handler); | 95 signal(SIGCHLD, &signal_handler); |
96 #endif | 96 #endif |
97 srand((unsigned int)time(NULL)); | 97 srand((unsigned int)time(NULL)); |
98 | 98 |
99 if (cmd_line.HasSwitch(std::string("port"))) { | 99 if (cmd_line.HasSwitch(std::string("port"))) { |
100 port = cmd_line.GetSwitchValueASCII(std::string("port")); | 100 port = cmd_line.GetSwitchValueASCII(std::string("port")); |
101 } | 101 } |
102 | 102 |
103 LOG(INFO) << "Using port: " << port; | 103 VLOG(1) << "Using port: " << port; |
104 webdriver::SessionManager* session = | 104 webdriver::SessionManager* session = |
105 Singleton<webdriver::SessionManager>::get(); | 105 Singleton<webdriver::SessionManager>::get(); |
106 session->SetIPAddress(port); | 106 session->SetIPAddress(port); |
107 | 107 |
108 // Initialize SHTTPD context. | 108 // Initialize SHTTPD context. |
109 // Listen on port 8080 or port specified on command line. | 109 // Listen on port 8080 or port specified on command line. |
110 // TODO(jmikhail) Maybe add port 8081 as a secure connection. | 110 // TODO(jmikhail) Maybe add port 8081 as a secure connection. |
111 ctx = mg_start(); | 111 ctx = mg_start(); |
112 mg_set_option(ctx, "ports", port.c_str()); | 112 mg_set_option(ctx, "ports", port.c_str()); |
113 | 113 |
114 webdriver::InitCallbacks(ctx); | 114 webdriver::InitCallbacks(ctx); |
115 | 115 |
116 std::cout << "Starting server" << std::endl; | 116 std::cout << "Starting server" << std::endl; |
117 // The default behavior is to run this service forever. | 117 // The default behavior is to run this service forever. |
118 while (true) { | 118 while (true) |
119 PlatformThread::Sleep(3600); | 119 PlatformThread::Sleep(3600); |
120 } | |
121 | 120 |
122 // We should not reach here since the service should never quit. | 121 // We should not reach here since the service should never quit. |
123 // TODO(jmikhail): register a listener for SIGTERM and break the | 122 // TODO(jmikhail): register a listener for SIGTERM and break the |
124 // message loop gracefully. | 123 // message loop gracefully. |
125 mg_stop(ctx); | 124 mg_stop(ctx); |
126 return (EXIT_SUCCESS); | 125 return (EXIT_SUCCESS); |
127 } | 126 } |
128 | 127 |
OLD | NEW |