37 #include "../util/pool.h" |
37 #include "../util/pool.h" |
38 #include "../public/nsapi.h" |
38 #include "../public/nsapi.h" |
39 #include "../util/plist.h" |
39 #include "../util/plist.h" |
40 #include "../util/date.h" |
40 #include "../util/date.h" |
41 |
41 |
|
42 #include "../../ucx/string.h" |
|
43 |
42 #include "webserver.h" |
44 #include "webserver.h" |
43 #include "log.h" |
45 #include "log.h" |
44 #include "httprequest.h" |
46 #include "httprequest.h" |
45 #include "httplistener.h" |
47 #include "httplistener.h" |
|
48 #include "srvctrl.h" |
46 |
49 |
47 #include "configmanager.h" |
50 #include "configmanager.h" |
48 |
51 |
49 static int std_pipe_fds[2]; |
52 static int std_pipe_fds[2]; |
50 static WSBool is_daemon; |
53 static WSBool is_daemon; |
162 log_ereport(LOG_INFORM, "startup"); |
165 log_ereport(LOG_INFORM, "startup"); |
163 |
166 |
164 int status; |
167 int status; |
165 status = webserver_init(); |
168 status = webserver_init(); |
166 if(status != 0) { |
169 if(status != 0) { |
167 log_ereport(LOG_FAILURE, "Cannot initialize server."); |
170 log_ereport(LOG_FAILURE, "cannot initialize server."); |
168 return EXIT_FAILURE; |
171 return EXIT_FAILURE; |
169 } |
172 } |
170 |
173 |
171 status = webserver_run(); |
174 status = webserver_run(); |
172 if(status != 0) { |
175 if(status != 0) { |
173 log_ereport(LOG_FAILURE, "Cannot run server."); |
176 log_ereport(LOG_FAILURE, "cannot run server."); |
174 return EXIT_FAILURE; |
177 return EXIT_FAILURE; |
175 } |
178 } |
176 |
179 |
|
180 if(srvctrl_wait()) { |
|
181 return EXIT_FAILURE; |
|
182 } |
|
183 |
177 /* TODO: join threads (or not?) */ |
184 /* TODO: join threads (or not?) */ |
|
185 /* |
178 while(1) { |
186 while(1) { |
179 if(is_daemon) { |
187 if(is_daemon) { |
180 fflush(stdout); |
188 fflush(stdout); |
181 fflush(stderr); |
189 fflush(stderr); |
182 } |
190 } |
183 sleep(10000); |
191 sleep(10000); |
184 if(0) { |
192 if(0) { |
185 break; |
193 break; |
186 } |
194 } |
187 } |
195 } |
|
196 */ |
188 |
197 |
189 return EXIT_SUCCESS; |
198 return EXIT_SUCCESS; |
190 } |
199 } |
191 |
200 |