-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
24 lines (18 loc) · 797 Bytes
/
Copy pathmain.cpp
File metadata and controls
24 lines (18 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "server.hpp"
int main(int argc, char* argv[]) {
int port = 8080;
int node_id = 1;
if (argc > 1) port = std::stoi(argv[1]);
if (argc > 2) node_id = std::stoi(argv[2]);
std::string node_name = "127.0.0.1:" + std::to_string(port);
std::string wal_file = "kvstore_" + std::to_string(port) + ".wal";
Server server(port, 4, wal_file, node_id, node_name);
server.add_cluster_node("127.0.0.1:8080");
server.add_cluster_node("127.0.0.1:8081");
server.add_cluster_node("127.0.0.1:8082");
if (port != 8080) server.get_raft().add_peer("127.0.0.1:8080");
if (port != 8081) server.get_raft().add_peer("127.0.0.1:8081");
if (port != 8082) server.get_raft().add_peer("127.0.0.1:8082");
server.run();
return 0;
}