mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-20 19:09:07 +01:00
83769ba715
This commits removes the locks used to guard data integrity for the database and replaces them with Transactions, turns out that SQL had a way to deal with this all along. This reduces the complexity we had with multiple locks that might stack or recurse (database, nofitifer, mapper). All notifications and state updates are now triggered _after_ a database change. Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
44 lines
875 B
Go
44 lines
875 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/efekarakus/termcolor"
|
|
"github.com/juanfont/headscale/cmd/headscale/cli"
|
|
"github.com/rs/zerolog"
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
func main() {
|
|
var colors bool
|
|
switch l := termcolor.SupportLevel(os.Stderr); l {
|
|
case termcolor.Level16M:
|
|
colors = true
|
|
case termcolor.Level256:
|
|
colors = true
|
|
case termcolor.LevelBasic:
|
|
colors = true
|
|
case termcolor.LevelNone:
|
|
colors = false
|
|
default:
|
|
// no color, return text as is.
|
|
colors = false
|
|
}
|
|
|
|
// Adhere to no-color.org manifesto of allowing users to
|
|
// turn off color in cli/services
|
|
if _, noColorIsSet := os.LookupEnv("NO_COLOR"); noColorIsSet {
|
|
colors = false
|
|
}
|
|
|
|
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
|
|
log.Logger = log.Output(zerolog.ConsoleWriter{
|
|
Out: os.Stderr,
|
|
TimeFormat: time.RFC3339,
|
|
NoColor: !colors,
|
|
})
|
|
|
|
cli.Execute()
|
|
}
|