Граф коммитов

23 Коммитов

Автор SHA1 Сообщение Дата
Michael Berlin 799b00ae04 vtworker: Fix problem that the Wrangler logger was overwritten with a ConsoleLogger when combining it with a memory logger for the webserver status output.
This problem occurred in case of RPC requests where the Logger of the custom Wrangler has to be preserved.

Reduced visiblity of Instance fields.
2015-06-30 14:18:43 +02:00
Michael Berlin c09d05d131 vtworker: Print flags Usage on logger instead of stderr.
This way, we can also return the usage to the vtworker RPC client.

Do not exit (or panic) when flags.parse() returned an error unless we are run from the command line.

Commands now return the error of the flag parsing.
Commands now show the usage if an optional parameter is missing.
2015-06-30 14:00:19 +02:00
Michael Berlin b417851a51 vtworker: Add exit.Return(0) back instead of os.Exit(0)
Unlike os.Exit(), exit.Return() supports to run all deferred functions from the *same* goroutine.

Please note that this doesn't have any effect in vtworker and did not in the past: While the main goroutine has several defer calls to close opened resources, they won't be triggered because the vtworker command is executed in a different go routine. (The main go routine is blocked by servenv.RunDefault())
2015-06-24 13:32:36 +02:00
Michael Berlin 3fa02d1210 vtworker: Rename WorkerInstance struct to Instance as suggested by golint. 2015-06-23 16:36:21 +02:00
Michael Berlin 1a0e5b6fe6 vtworker: Make RunCommand() blocking.
Before this change, RunCommand returned immediately which doesn't work well when we call it from an RPC.
2015-06-23 16:35:19 +02:00
Michael Berlin ead93164d2 vtworker: Refactored CLI args parsing.
I moved all code relevant for command parsing and running a command from
"cmd/vtworker" to "vt/worker" because I ran into an import cycle with
the gRPC interface:

cmd/vtworker [plugin_grpcvtworkerserver.go]
 => imports vt/worker/grpcvtworkerserver [server.go]
  => imports cmd/vtworker [command.go]

The only alternative would have been to move the gRPC vtworker server
into the cmd/vtworker package as well?

vtctld does not have the same problem because all its command line
parsing code is already below vt/vtctl and not cmd/vtctl.

As part of the change, I've moved the global variables of vtworker.go
into a new struct "WorkerInstance" which encapsulates the complete
execution state of vtworker. If you prefer, we can also move this into a
separate package.
(Note: In instance.go, setAndStartWorker() and InstallSignalHandlers()
were moved from vtworker.go)
2015-06-22 20:59:42 +02:00
Alain Jobart ded4a347c3 Refactoring Worker to have an explicit context.Context. 2015-05-18 16:22:26 -07:00
Ammar Aijazi 736cee1053 Modify Wrangler to take in a TabletManagerClient at creation 2015-02-03 15:49:02 -08:00
Ammar Aijazi 202b3e81bc Workers will be canceled via their context instead of an interrupt channel 2015-01-16 18:19:21 -08:00
Anthony Yeh e08d919ea9 Return error instead of log.Fatal in vtworker commands. 2015-01-12 15:46:09 -08:00
Alain Jobart fe41d8ee83 Wrangler has no more context. 2015-01-06 20:44:52 -08:00
Alain Jobart 8fe6283edc Using context in all the topo server lock methods.
So we can remove timeout and interrupted.
Removing global wrangler interrupted channel, now just
cancelling its context.
2014-12-15 09:27:37 -08:00
Alain Jobart a4f79d943c Removing initiator, it is an extra layer for nothing. 2014-10-06 14:47:15 -07:00
Alain Jobart 17d58a42c2 Adding TeeLogger. Using it in vtowrker. 2014-10-03 16:04:11 -07:00
Alain Jobart 5b9da5b4b7 Workers now use Logger. 2014-08-14 14:28:30 -07:00
Alain Jobart 53c70f07df Adding a Logger interface, tests and using it.
This is so we can have background operations that log,
and keep the logs. We can then display them on a web page
or on the console depending on the usage.
(this is part of vtctl refactor).
2014-08-14 11:46:09 -07:00
Alain Jobart 9f125f98b8 Second part of servenv rework.
lameduckMode flag is not local (not used anywhere else).
Allowing default flags and non-default flags to be used.
Always using default flags in our applications.
2014-06-16 15:27:45 -07:00
Alain Jobart de8060b3f1 Moving port parameter to servenv. 2014-03-06 10:31:49 -08:00
Alain Jobart 67ea8c4be5 Moving tabletmanager client to its own lib
Most dependencies for clients are now clean, they don't
include server code.
2014-01-24 11:04:48 -08:00
Alain Jobart 2756d39773 Removing the tabletmanager->tm rename. 2014-01-16 11:24:38 -08:00
Alain Jobart 24fbf86be6 Adding 'checker' type, working on split_diff. 2013-12-13 17:12:04 -08:00
Alain Jobart 42c6730d86 More work on vtworker. The framework is good now. 2013-12-13 16:08:10 -08:00
Alain Jobart b74c92fc1f First phase of vtworker: commandline framework. 2013-12-13 11:16:56 -08:00