异常抛出
This commit is contained in:
@@ -17,23 +17,23 @@
|
||||
#endif
|
||||
struct Catch_Memory {
|
||||
Catch_Memory() {
|
||||
sm = (std::int64_t)get_system_memory();
|
||||
cur = (std::int64_t)get_process_memory();
|
||||
sm = (std::int64_t) get_system_memory();
|
||||
cur = (std::int64_t) get_process_memory();
|
||||
}
|
||||
|
||||
std::int64_t MB = 1024 * 1024;
|
||||
|
||||
bool catch_ok() {
|
||||
auto old_memory = cur;
|
||||
cur = (std::int64_t)get_process_memory();
|
||||
cur = (std::int64_t) get_process_memory();
|
||||
auto change_mb = (cur - old_memory) / MB;
|
||||
auto cur_mb = cur / MB;
|
||||
// std::cout << get_current_date_string() << " 时内存" << cur_mb << "MB "
|
||||
// << " 变更" << change_mb << "MB" << std::endl;
|
||||
if (cur > memory_max) {
|
||||
auto rate = (double)cur / (double)sm;
|
||||
auto rate = (double) cur / (double) sm;
|
||||
std::cout << get_current_date_string() + " 抓住内存暴涨:" << cur_mb
|
||||
<< "MB" << " 变更" << change_mb << "MB" << std::endl;
|
||||
<< "MB" << " 变更" << change_mb << "MB" << std::endl;
|
||||
std::cout << "\t内存占用" << rate << "%" << std::endl;
|
||||
stop_program = SIGINT;
|
||||
#if WIN32
|
||||
@@ -53,7 +53,7 @@ struct Catch_Memory {
|
||||
std::int64_t sm;
|
||||
};
|
||||
|
||||
int psc_main(int argc, char* argv[]) {
|
||||
int psc_main(int argc, char *argv[]) {
|
||||
std::cout << "wyc_main" << std::endl;
|
||||
if (argc >= 2) {
|
||||
std::string config_path = argv[1];
|
||||
@@ -95,7 +95,7 @@ int psc_main(int argc, char* argv[]) {
|
||||
std::cout << "shutdown" << LOG_POS << std::endl;
|
||||
auto id = std::this_thread::get_id();
|
||||
std::cout << "id: " << id << std::endl;
|
||||
Detach_Thread* dt = g->thread_manager.get_thread(id);
|
||||
Detach_Thread *dt = g->thread_manager.get_thread(id);
|
||||
if (!dt) {
|
||||
std::cout << VAR_STR_1((void*)dt) << std::endl;
|
||||
std::terminate();
|
||||
@@ -118,30 +118,30 @@ int psc_main(int argc, char* argv[]) {
|
||||
std::exit(75);
|
||||
std::cout << "std::exit(75) 完成:" << name << std::endl;
|
||||
});
|
||||
Detach_Thread_Manager& manager = g->thread_manager;
|
||||
Detach_Thread_Manager &manager = g->thread_manager;
|
||||
std::cout << "[主线程:" << std::this_thread::get_id() << "]" << " \n"
|
||||
<< std::flush;
|
||||
<< std::flush;
|
||||
manager.test_and_start_thread(
|
||||
"web服务器线程", [g](std::atomic<bool>& running) {
|
||||
auto& c = Global::instance()->device_config;
|
||||
"web服务器线程", [g](std::atomic<bool> &running) {
|
||||
auto &c = Global::instance()->device_config;
|
||||
std::string ip = "0.0.0.0";
|
||||
#ifdef WIN32
|
||||
ip = "127.0.0.1";
|
||||
#endif
|
||||
Net_Config* device = c.list.get("device").value();
|
||||
Net_Config *device = c.list.get("device").value();
|
||||
std::cout << "http://" + ip + ":" + std::to_string(device->port) + "\n"
|
||||
<< std::flush;
|
||||
<< std::flush;
|
||||
std::cout << "http://" + device->ip + ":" +
|
||||
std::to_string(device->port) + "\n"
|
||||
<< std::flush;
|
||||
std::to_string(device->port) + "\n"
|
||||
<< std::flush;
|
||||
if (!g->svr.listen("0.0.0.0", device->port)) {
|
||||
if (running.load(std::memory_order_acquire)) {
|
||||
std::cout << "http://" + ip + ":" + std::to_string(device->port) +
|
||||
"启动失败 退出!\n"
|
||||
<< std::flush;
|
||||
"启动失败 退出!\n"
|
||||
<< std::flush;
|
||||
std::cout << "http://" + device->ip + ":" +
|
||||
std::to_string(device->port) + "启动失败 退出!\n"
|
||||
<< std::flush;
|
||||
std::to_string(device->port) + "启动失败 退出!\n"
|
||||
<< std::flush;
|
||||
std::exit(0);
|
||||
}
|
||||
}
|
||||
@@ -154,7 +154,7 @@ int psc_main(int argc, char* argv[]) {
|
||||
coro->start();
|
||||
// Catch_Memory cm;
|
||||
while (stop_program == 0) {
|
||||
for (auto& ds : g->mode_acs.data_source_config.map.list()) {
|
||||
for (auto &ds: g->mode_acs.data_source_config.map.list()) {
|
||||
ds->delete_timeout_aircraft();
|
||||
}
|
||||
if (enable) {
|
||||
@@ -179,6 +179,6 @@ int psc_main(int argc, char* argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int main(int argc, char *argv[]) {
|
||||
return redict_main_with_gtest(argc, argv, psc_main);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user