-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
43 lines (36 loc) · 1.17 KB
/
Copy pathmain.cpp
File metadata and controls
43 lines (36 loc) · 1.17 KB
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
#include "./config/config.h"
#include "webserver.h"
#include "./CGImysql/sql_connection_pool.h"
#include "./analytics/click_event_producer.h"
#include "./handler/health_handler.h"
#include "./handler/metrics_handler.h"
#include "./handler/short_url_handler.h"
#include "./observability/structured_logger.h"
#include "./shorturl/short_url_cache.h"
#include "./shorturl/shard_router.h"
int main(int argc, char *argv[])
{
Config config;
std::string config_path = "config/config.yaml";
if (argc > 1)
config_path = argv[1];
if (!config.load(config_path))
fprintf(stderr, "Config load failed, using defaults\n");
ShardRouter::instance().init(config);
StructuredLogger::instance().init(config);
ShortUrlCache::instance().init(config);
ClickEventProducer::instance().init(config);
register_health_routes();
register_metrics_routes();
register_short_url_routes();
WebServer server;
server.init(config);
server.log_write();
server.sql_pool();
ShortUrlCache::instance().warmup(connection_pool::GetInstance());
server.thread_pool();
server.trig_mode();
server.eventListen();
server.eventLoop();
return 0;
}