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