這篇文章主要介紹“rgw內(nèi)置civetweb的參數(shù)初始化怎么實現(xiàn)”,在日常操作中,相信很多人在rgw內(nèi)置civetweb的參數(shù)初始化怎么實現(xiàn)問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”rgw內(nèi)置civetweb的參數(shù)初始化怎么實現(xiàn)”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
在臨城等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供網(wǎng)站設(shè)計制作、成都網(wǎng)站設(shè)計 網(wǎng)站設(shè)計制作按需設(shè)計網(wǎng)站,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站制作,營銷型網(wǎng)站,外貿(mào)營銷網(wǎng)站建設(shè),臨城網(wǎng)站建設(shè)費用合理。
1. 初始化civetweb時刻的參數(shù)傳遞
src/civetweb/civetweb.h
/* Start web server. Parameters: callbacks: mg_callbacks structure with user-defined callbacks. options: NULL terminated list of option_name, option_value pairs that specify Civetweb configuration parameters. Side-effects: on UNIX, ignores SIGCHLD and SIGPIPE signals. If custom processing is required for these, signal handlers must be set up after calling mg_start(). Example: const char *options[] = { "document_root", "/var/www", "listening_ports", "80,443s", NULL }; struct mg_context *ctx = mg_start(&my_func, NULL, options); Refer to https://github.com/bel2125/civetweb/blob/master/docs/UserManual.md for the list of valid option and their possible values. Return: web server context, or NULL on error. */ CIVETWEB_API struct mg_context *mg_start(const struct mg_callbacks *callbacks, void *user_data, const char **configuration_options);
civetweb啟動時的參數(shù)初始化由mg_start函數(shù)實現(xiàn),注意configuration_options為具體的配置參數(shù)
src/rgw/rgw_civetweb_frontend.cc
int RGWMongooseFrontend::run() { char thread_pool_buf[32]; snprintf(thread_pool_buf, sizeof(thread_pool_buf), "%d", (int)g_conf->rgw_thread_pool_size); string port_str; mapconf_map = conf->get_config_map(); conf->get_val("port", "80", &port_str); conf_map.erase("port"); conf_map["listening_ports"] = port_str; #默認端口設(shè)置 set_conf_default(conf_map, "enable_keep_alive", "yes"); #默認開啟了keepalive set_conf_default(conf_map, "num_threads", thread_pool_buf); #從rgw_thread_pool_size這個配置項中讀取對應(yīng)的并發(fā)數(shù) set_conf_default(conf_map, "decode_url", "no"); // Set run_as_user. This will cause civetweb to invoke setuid() and setgid() // based on pw_uid and pw_gid obtained from pw_name. string uid_string = g_ceph_context->get_set_uid_string(); if (!uid_string.empty()) { conf_map.erase("run_as_user"); conf_map["run_as_user"] = uid_string; } const char *options[conf_map.size() * 2 + 1]; int i = 0; for (map ::iterator iter = conf_map.begin(); iter != conf_map.end(); ++iter) { options[i] = iter->first.c_str(); options[i + 1] = iter->second.c_str(); dout(20)<< "civetweb config: " << options[i] << ": " << (options[i + 1] ? options[i + 1] : " ") << dendl; i += 2; } options[i] = NULL; struct mg_callbacks cb; memset((void *)&cb, 0, sizeof(cb)); cb.begin_request = civetweb_callback; cb.log_message = rgw_civetweb_log_callback; cb.log_access = rgw_civetweb_log_access_callback; ctx = mg_start(&cb, &env, (const char **)&options);#啟動civetweb if (!ctx) { return -EIO; } return 0; } /* RGWMongooseFrontend::run */
通過RGWMongooseFrontend的run方法,實現(xiàn)了civetweb的啟動參數(shù)初始化。
Limit download speed for clients. throttle is a comma-separated list of key=value pairs, where key could be:
* limit speed for all connections x.x.x.x/mask limit speed for specified subnet uri_prefix_pattern limit speed for given URIs
The value is a floating-point number of bytes per second, optionally followed by a k or m character, meaning kilobytes and megabytes respectively. A limit of 0 means unlimited rate. The last matching rule wins. Examples:
*=1k,10.0.0.0/8=0 limit all accesses to 1 kilobyte per second, but give connections the from 10.0.0.0/8 subnet unlimited speed /downloads/=5k limit accesses to all URIs in `/downloads/` to 5 kilobytes per second. All other accesses are unlimited
可以實現(xiàn)針對不同的subnet和URL設(shè)置下載速度,在需要限速的場景下比較有用
An Access Control List (ACL) allows restrictions to be put on the list of IP addresses which have access to the web server. In the case of the Civetweb web server, the ACL is a comma separated list of IP subnets, where each subnet is pre-pended by either a - or a + sign. A plus sign means allow, where a minus sign means deny. If a subnet mask is omitted, such as -1.2.3.4, this means to deny only that single IP address.
Subnet masks may vary from 0 to 32, inclusive. The default setting is to allow all accesses. On each request the full list is traversed, and the last match wins. Examples:
-0.0.0.0/0,+192.168/16 deny all accesses, only allow 192.168/16 subnet
這個應(yīng)該都比較熟了,ACL控制哪些subnet或者host可以訪問
Number of worker threads. Civetweb handles each incoming connection in a separate thread. Therefore, the value of this option is effectively the number of concurrent HTTP connections Civetweb can handle.
控制單個civetweb實例的最大并發(fā)數(shù)
This option can be used to enable or disable the use of the Linux sendfile system call. It is only available for Linux systems and only affecting HTTP (not HTTPS) connections if throttle is not enabled. While using the sendfile call will lead to a performance boost for HTTP connections, this call may be broken for some file systems and some operating system versions.
援引一段對sendfile特性的描述
sendfile() copies data between one file descriptor and another.Because this copying is done within the kernel, sendfile() is more efficient than the combination of read(2) and write(2), which would require transferring data to and from user space.
啟動該特性以后部分數(shù)據(jù)復制操作將在內(nèi)核內(nèi)部完成,能夠減少上下文切換帶來的性能損耗。
到此,關(guān)于“rgw內(nèi)置civetweb的參數(shù)初始化怎么實現(xiàn)”的學習就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
分享文章:rgw內(nèi)置civetweb的參數(shù)初始化怎么實現(xiàn)
新聞來源:http://weahome.cn/article/gspjes.html