: count{cnt}
, proto{move(serv)}
{
- if (count < 4) {
- count = stoi(getenv_else("MEMCACHED_CLUSTER", "4"));
- }
if (!count) {
count = 1;
}
}
}
-Cluster::Cluster(vector<Server> servers)
-: count{servers.size()}
-, cluster{move(servers)}
-{
-
-}
-
Cluster::~Cluster() {
stop();
wait();
return started;
}
-void Cluster::stop() {
+void Cluster::stop(bool graceful) {
for (auto &server : cluster) {
server.drain();
- // no cookies for memcached; TERM is just too slow
- server.signal(SIGKILL);
+ if (graceful) {
+ server.stop();
+ } else {
+ // no cookies for memcached; TERM is just too slow
+ server.signal(SIGKILL);
+ }
}
}