Added tests to validate the process receiving signals:
- SIGTERM and SIGINT exit.
- SIGUSR2 swaps logs
Removed the empty Fprintln in main. Turns out stderr isn't thread safe
to write from multiple locations. The logger, which is otherwise the
only stderr writing goroutine creates a sync writer. But the stderr in
main remains unsafe. This is something to fix later?
There are also races happening with the swap log test, but only when the
test runs in parallel. I'm not sure what's happening there... added a
flag to make this test synchronous for now.
Tests that depend on signals don't run on windows. That's a big todo.
I moved SIGUSR2 behind build tags, so the binary will at least compile.
- Added the concept of a "trace id", a unique ID which gets associated
with every log/request by default. Will eventually use
opentelemetry/opentracing, or perhaps something better... Still very
alpha quality + lots of dependencies/API surface to bring in. For the
purpose of MicroMDM, a unique identifier per request is fine.
- Added HTTP logging middleware.
The main change here is initializing micromdm.io as the module. That
allows micromdm to decouple from GitHub in the long run. It also means
I'll have to set up Go vanity URLs and move or modify the website
directory.
Other changes:
- WIP logging package
- Package id with ulid
- Tools repo