blob: b1e4ecac1f3234384ebbe4d1c9165e4bd29d97e8 [file] [log] [blame]
// Copyright 2023 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <stdio.h>
#include <stdlib.h>
#include "persistent_service.h"
#include "persistent_service_test_lib.cc"
void PrintUsage(const char* progname) {
fprintf(stderr, "Usage: %s [-t<timeout>] [-v<version>]\n", progname);
}
int main(int argc, char** argv) {
const char* progname = argv[0];
PersistentService::Server server(persistent_service_test::kServiceName);
std::string version = persistent_service_test::kDefaultVersion;
for (; argc > 1; --argc, argv++) {
const char* arg = argv[1];
if (arg[0] != '-') {
PrintUsage(progname);
return 1;
}
switch (arg[1]) {
case 't': // -t<value> Server timeout in milliseconds.
server.SetConnectionTimeoutMs(static_cast<int64_t>(atoll(arg + 2)));
break;
case 'v': // -v<version> is server version.
version = arg + 2;
break;
default:
PrintUsage(progname);
return 1;
}
}
server.RunServerThenExit(
persistent_service_test::GetVersionCheckHandler(version),
persistent_service_test::RequestHandler);
return 0;
}