diff options
author | Håvard Pettersen <havardpe@oath.com> | 2022-04-06 12:18:08 +0000 |
---|---|---|
committer | Håvard Pettersen <havardpe@oath.com> | 2022-04-08 13:45:13 +0000 |
commit | 9fbcf76d088740aacf535e6482f86c833cfae871 (patch) | |
tree | c62dcd0f9cdcee9876b37c60f741958c14147f80 /config | |
parent | 69454cef2fe53694eb5541e5f622a4e973c081bf (diff) |
remove FastOS_Application
fixup (per application):
- maybe ignore SIGPIPE
- wire argc/argv
untangle Vespa Test Framework
strip down deprecated TestApp
Diffstat (limited to 'config')
-rw-r--r-- | config/src/apps/vespa-configproxy-cmd/main.cpp | 33 | ||||
-rw-r--r-- | config/src/apps/vespa-get-config/getconfig.cpp | 28 | ||||
-rw-r--r-- | config/src/apps/vespa-ping-configproxy/pingproxy.cpp | 28 |
3 files changed, 44 insertions, 45 deletions
diff --git a/config/src/apps/vespa-configproxy-cmd/main.cpp b/config/src/apps/vespa-configproxy-cmd/main.cpp index 2af645b9351..28ebf454084 100644 --- a/config/src/apps/vespa-configproxy-cmd/main.cpp +++ b/config/src/apps/vespa-configproxy-cmd/main.cpp @@ -2,26 +2,26 @@ #include "proxycmd.h" #include "methods.h" -#include <vespa/fastos/app.h> +#include <vespa/vespalib/util/signalhandler.h> #include <iostream> #include <unistd.h> -class Application : public FastOS_Application +class Application { Flags _flags; - bool parseOpts(); + bool parseOpts(int argc, char **argv); public: void usage(); - int Main() override; + int main(int argc, char **argv); Application() : _flags() {} }; bool -Application::parseOpts() +Application::parseOpts(int argc, char **argv) { int c = '?'; - while ((c = getopt(_argc, _argv, "m:s:p:h")) != -1) { + while ((c = getopt(argc, argv, "m:s:p:h")) != -1) { switch (c) { case 'm': _flags.method = optarg; @@ -38,18 +38,18 @@ Application::parseOpts() } } const Method method = methods::find(_flags.method); - if (optind + method.args <= _argc) { + if (optind + method.args <= argc) { for (int i = 0; i < method.args; ++i) { - vespalib::string arg = _argv[optind++]; + vespalib::string arg = argv[optind++]; _flags.args.push_back(arg); } } else { std::cerr << "ERROR: method "<< _flags.method << " requires " << method.args - << " arguments, only got " << (_argc - optind) << std::endl; + << " arguments, only got " << (argc - optind) << std::endl; return false; } - if (optind != _argc) { - std::cerr << "ERROR: "<<(_argc - optind)<<" extra arguments\n"; + if (optind != argc) { + std::cerr << "ERROR: "<<(argc - optind)<<" extra arguments\n"; return false; } _flags.method = method.rpcMethod; @@ -69,9 +69,9 @@ Application::usage(void) } int -Application::Main(void) +Application::main(int argc, char **argv) { - if (! parseOpts()) { + if (! parseOpts(argc, argv)) { usage(); return 1; } @@ -79,9 +79,8 @@ Application::Main(void) return client.action(); } -int -main(int argc, char** argv) -{ +int main(int argc, char** argv) { + vespalib::SignalHandler::PIPE.ignore(); Application app; - return app.Entry(argc, argv); + return app.main(argc, argv); } diff --git a/config/src/apps/vespa-get-config/getconfig.cpp b/config/src/apps/vespa-get-config/getconfig.cpp index e62521d8db1..74380390095 100644 --- a/config/src/apps/vespa-get-config/getconfig.cpp +++ b/config/src/apps/vespa-get-config/getconfig.cpp @@ -11,7 +11,7 @@ #include <vespa/config/common/configstate.h> #include <vespa/config/common/configresponse.h> #include <vespa/config/common/trace.h> -#include <vespa/fastos/app.h> +#include <vespa/vespalib/util/signalhandler.h> #include <unistd.h> #include <sstream> @@ -22,7 +22,7 @@ LOG_SETUP("vespa-get-config"); using namespace config; -class GetConfig : public FastOS_Application +class GetConfig { private: std::unique_ptr<fnet::frt::StandaloneFRT> _server; @@ -33,11 +33,11 @@ private: public: GetConfig() : _server(), _target(nullptr) {} - ~GetConfig() override; - int usage(); + ~GetConfig(); + int usage(const char *self); void initRPC(const char *spec); void finiRPC(); - int Main() override; + int main(int argc, char **argv); }; @@ -49,9 +49,9 @@ GetConfig::~GetConfig() int -GetConfig::usage() +GetConfig::usage(const char *self) { - fprintf(stderr, "usage: %s -n name -i configId\n", _argv[0]); + fprintf(stderr, "usage: %s -n name -i configId\n", self); fprintf(stderr, "-n name (config name, including namespace, on the form <namespace>.<name>)\n"); fprintf(stderr, "-i configId (config id, optional)\n"); fprintf(stderr, "-j (output config as json, optional)\n"); @@ -92,7 +92,7 @@ GetConfig::finiRPC() int -GetConfig::Main() +GetConfig::main(int argc, char **argv) { bool debugging = false; int c = -1; @@ -118,7 +118,7 @@ GetConfig::Main() int serverPort = 19090; - while ((c = getopt(_argc, _argv, "a:n:v:g:i:jlm:c:t:V:w:r:s:p:dh")) != -1) { + while ((c = getopt(argc, argv, "a:n:v:g:i:jlm:c:t:V:w:r:s:p:dh")) != -1) { int retval = 1; switch (c) { case 'a': @@ -170,13 +170,13 @@ GetConfig::Main() [[fallthrough]]; case '?': default: - usage(); + usage(argv[0]); return retval; } } if (defName == nullptr || serverPort == 0) { - usage(); + usage(argv[0]); return 1; } @@ -275,8 +275,8 @@ GetConfig::Main() return 0; } -int main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); GetConfig app; - return app.Entry(argc, argv); + return app.main(argc, argv); } diff --git a/config/src/apps/vespa-ping-configproxy/pingproxy.cpp b/config/src/apps/vespa-ping-configproxy/pingproxy.cpp index 92d07b743f5..e8423eba233 100644 --- a/config/src/apps/vespa-ping-configproxy/pingproxy.cpp +++ b/config/src/apps/vespa-ping-configproxy/pingproxy.cpp @@ -3,7 +3,7 @@ #include <vespa/fnet/frt/supervisor.h> #include <vespa/fnet/frt/target.h> #include <vespa/fnet/frt/rpcrequest.h> -#include <vespa/fastos/app.h> +#include <vespa/vespalib/util/signalhandler.h> #include <unistd.h> #include <sstream> @@ -12,7 +12,7 @@ LOG_SETUP("vespa-ping-configproxy"); -class PingProxy : public FastOS_Application +class PingProxy { private: std::unique_ptr<fnet::frt::StandaloneFRT> _server; @@ -22,11 +22,11 @@ public: PingProxy(const PingProxy &) = delete; PingProxy &operator=(const PingProxy &) = delete; PingProxy() : _server(), _target(nullptr) {} - ~PingProxy() override ; - int usage(); + ~PingProxy(); + int usage(const char *self); void initRPC(const char *spec); void finiRPC(); - int Main() override; + int main(int argc, char **argv); }; @@ -38,9 +38,9 @@ PingProxy::~PingProxy() int -PingProxy::usage() +PingProxy::usage(const char *self) { - fprintf(stderr, "usage: %s\n", _argv[0]); + fprintf(stderr, "usage: %s\n", self); fprintf(stderr, "-s [server] (server hostname, default localhost)\n"); fprintf(stderr, "-p [port] (server port number, default 19090)\n"); return 1; @@ -67,7 +67,7 @@ PingProxy::finiRPC() int -PingProxy::Main() +PingProxy::main(int argc, char **argv) { int retval = 0; bool debugging = false; @@ -77,7 +77,7 @@ PingProxy::Main() int clientTimeout = 5; int serverPort = 19090; - while ((c = getopt(_argc, _argv, "w:s:p:dh")) != -1) { + while ((c = getopt(argc, argv, "w:s:p:dh")) != -1) { switch (c) { case 'w': clientTimeout = atoi(optarg); @@ -96,13 +96,13 @@ PingProxy::Main() retval = 1; [[fallthrough]]; case 'h': - usage(); + usage(argv[0]); return retval; } } if (serverPort == 0) { - usage(); + usage(argv[0]); return 1; } @@ -151,8 +151,8 @@ PingProxy::Main() return retval; } -int main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); PingProxy app; - return app.Entry(argc, argv); + return app.main(argc, argv); } |