1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
| start up the RADOS connection and then handle HTTP messages as they come in / int main(int argc, const char **argv) { TEMP_FAILURE_RETRY(close(STDERR_FILENO)); if (TEMP_FAILURE_RETRY(dup2(STDOUT_FILENO, STDERR_FILENO) < 0)) { int err = errno; cout << “failed to redirect stderr to stdout: “ << cpp_strerror(err) << std::endl; return ENOSYS; }
vector<const char > def_args; def_args.push_back(“–debug-rgw=1/5”); def_args.push_back(“–keyring=$rgw_data/keyring”); def_args.push_back(“–log-file=/var/log/radosgw/$cluster-$name.log”);
vector<const char> args; argv_to_vec(argc, argv, args); env_to_vec(args); global_init(&def_args, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_DAEMON, CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS);
for (std::vector<const char>::iterator i = args.begin(); i != args.end(); ++i) { if (ceph_argparse_flag(args, i, “-h”, “–help”, (char)NULL)) { usage(); return 0; } }
check_curl();
if (g_conf->daemonize) { global_init_daemonize(g_ceph_context, 0); } Mutex mutex(“main”); SafeTimer init_timer(g_ceph_context, mutex); init_timer.init(); mutex.Lock(); init_timer.add_event_after(g_conf->rgw_init_timeout, new C_InitTimeout); mutex.Unlock();
common_init_finish(g_ceph_context);
rgw_tools_init(g_ceph_context);
rgw_init_resolver(); rgw_rest_init(g_ceph_context);
curl_global_init(CURL_GLOBAL_ALL); FCGX_Init();
int r = 0; RGWRados store = RGWStoreManager::get_storage(g_ceph_context, true, true); if (!store) { derr << “Couldn’t init storage provider (RADOS)” << dendl; r = EIO; } if (!r) r = rgw_perf_start(g_ceph_context);
mutex.Lock(); init_timer.cancel_all_events(); init_timer.shutdown(); mutex.Unlock();
if (r) return 1;
rgw_user_init(store->meta_mgr); rgw_bucket_init(store->meta_mgr); rgw_log_usage_init(g_ceph_context, store);
RGWREST rest;
list<string> apis; bool do_swift = false;
get_str_list(g_conf->rgw_enable_apis, apis);
map<string, bool> apis_map; for (list<string>::iterator li = apis.begin(); li != apis.end(); ++li) { apis_map[li] = true; }
if (apis_map.count(“s3”) > 0) rest.register_default_mgr(set_logging(new RGWRESTMgr_S3));
if (apis_map.count(“swift”) > 0) { do_swift = true; swift_init(g_ceph_context); rest.register_resource(g_conf->rgw_swift_url_prefix, set_logging(new RGWRESTMgr_SWIFT)); }
if (apis_map.count(“swift_auth”) > 0) rest.register_resource(g_conf->rgw_swift_auth_entry, set_logging(new RGWRESTMgr_SWIFT_Auth));
if (apis_map.count(“admin”) > 0) { RGWRESTMgr_Admin admin_resource = new RGWRESTMgr_Admin; admin_resource->register_resource(“usage”, new RGWRESTMgr_Usage); admin_resource->register_resource(“user”, new RGWRESTMgr_User); admin_resource->register_resource(“bucket”, new RGWRESTMgr_Bucket); admin_resource->register_resource(“metadata”, new RGWRESTMgr_Metadata); admin_resource->register_resource(“log”, new RGWRESTMgr_Log); admin_resource->register_resource(“opstate”, new RGWRESTMgr_Opstate); admin_resource->register_resource(“replica_log”, new RGWRESTMgr_ReplicaLog); admin_resource->register_resource(“config”, new RGWRESTMgr_Config); rest.register_resource(g_conf->rgw_admin_entry, admin_resource); }
OpsLogSocket olog = NULL;
if (!g_conf->rgw_ops_log_socket_path.empty()) { olog = new OpsLogSocket(g_ceph_context, g_conf->rgw_ops_log_data_backlog); olog->init(g_conf->rgw_ops_log_socket_path); }
r = signal_fd_init(); if (r < 0) { derr << “ERROR: unable to initialize signal fds” << dendl; exit(1); }
init_async_signal_handler(); register_async_signal_handler(SIGHUP, sighup_handler); register_async_signal_handler(SIGTERM, handle_sigterm); register_async_signal_handler(SIGINT, handle_sigterm); register_async_signal_handler(SIGUSR1, handle_sigterm); sighandler_alrm = signal(SIGALRM, godown_alarm);
string frontend_frameworks = g_conf->rgw_frontends;
list<string> frontends;
get_str_list(g_conf->rgw_frontends, “,”, frontends);
multimap<string, RGWFrontendConfig > fe_map; list<RGWFrontendConfig > configs; if (frontends.empty()) { frontends.push_back(“fastcgi”); } for (list<string>::iterator iter = frontends.begin(); iter != frontends.end(); ++iter) { string& f = iter;
RGWFrontendConfig config = new RGWFrontendConfig(f); int r = config->init(); if (r < 0) { cerr << “ERROR: failed to init config: “ << f << std::endl; return EINVAL; }
configs.push_back(config);
string framework = config->get_framework(); fe_map.insert(make_pair<string, RGWFrontendConfig >(framework, config)); }
list<RGWFrontend > fes;
for (multimap<string, RGWFrontendConfig >::iterator fiter = fe_map.begin(); fiter != fe_map.end(); ++fiter) { RGWFrontendConfig config = fiter->second; string framework = config->get_framework(); RGWFrontend fe; if (framework == “fastcgi” || framework == “fcgi”) { RGWProcessEnv fcgi_pe = { store, &rest, olog, 0 };
fe = new RGWFCGXFrontend(fcgi_pe, config); } else if (framework == “civetweb” || framework == “mongoose”) { string err;
int port; config->get_val(“port”, 80, &port);
RGWProcessEnv env = { store, &rest, olog, port };
fe = new RGWMongooseFrontend(env, config); } else if (framework == “loadgen”) { int port; config->get_val(“port”, 80, &port);
RGWProcessEnv env = { store, &rest, olog, port };
fe = new RGWLoadGenFrontend(env, config); } else { dout(0) << “WARNING: skipping unknown framework: “ << framework << dendl; continue; } dout(0) << “starting handler: “ << fiter->first << dendl; int r = fe->init(); if (r < 0) { derr << “ERROR: failed initializing frontend” << dendl; return -r; } fe->run();
fes.push_back(fe); }
wait_shutdown();
derr << “shutting down” << dendl;
for (list<RGWFrontend >::iterator liter = fes.begin(); liter != fes.end(); ++liter) { RGWFrontend fe = liter; fe->stop(); }
for (list<RGWFrontend >::iterator liter = fes.begin(); liter != fes.end(); ++liter) { RGWFrontend fe = liter; fe->join(); delete fe; }
for (list<RGWFrontendConfig >::iterator liter = configs.begin(); liter != configs.end(); ++liter) { RGWFrontendConfig fec = *liter; delete fec; }
unregister_async_signal_handler(SIGHUP, sighup_handler); unregister_async_signal_handler(SIGTERM, handle_sigterm); unregister_async_signal_handler(SIGINT, handle_sigterm); unregister_async_signal_handler(SIGUSR1, handle_sigterm); shutdown_async_signal_handler();
if (do_swift) { swift_finalize(); }
rgw_log_usage_finalize();
delete olog;
rgw_perf_stop(g_ceph_context);
RGWStoreManager::close_storage(store);
rgw_tools_cleanup(); rgw_shutdown_resolver(); curl_global_cleanup();
dout(1) << “final shutdown” << dendl; g_ceph_context->put();
ceph::crypto::shutdown();
signal_fd_finalize();
return 0; }
|