aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2021-07-29 08:42:33 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2021-07-29 08:42:33 -0700
commit0c0b2680077c1103609c87a652bcc2263460b1d7 (patch)
tree9968655a20d3caec9077b49db2473cbdb344cb71 /client
parent95753255a17026750f5b53cc470999785e0c515f (diff)
Re-organize cmd paths
Diffstat (limited to 'client')
-rw-r--r--client/main.go114
-rw-r--r--client/mobius-client-config.yaml8
-rw-r--r--client/mobius-hotline-server.service13
3 files changed, 0 insertions, 135 deletions
diff --git a/client/main.go b/client/main.go
deleted file mode 100644
index ec6f895..0000000
--- a/client/main.go
+++ /dev/null
@@ -1,114 +0,0 @@
-package main
-
-import (
- "context"
- "flag"
- "fmt"
- "github.com/jhalter/mobius/hotline"
- "github.com/rivo/tview"
- "go.uber.org/zap"
- "go.uber.org/zap/zapcore"
- "log"
- "os"
- "os/signal"
- "runtime"
- "syscall"
-)
-
-func main() {
- _, cancelRoot := context.WithCancel(context.Background())
-
- sigChan := make(chan os.Signal, 1)
- signal.Notify(sigChan, syscall.SIGTERM, syscall.SIGINT, os.Interrupt)
-
- version := flag.Bool("version", false, "print version and exit")
- logLevel := flag.String("log-level", "info", "Log level")
- logFile := flag.String("log-file", "", "output logs to file")
-
- flag.Parse()
-
- if *version {
- fmt.Printf("v%s\n", hotline.VERSION)
- os.Exit(0)
- }
-
- zapLvl, ok := zapLogLevel[*logLevel]
- if !ok {
- fmt.Printf("Invalid log level %s. Must be debug, info, warn, or error.\n", *logLevel)
- os.Exit(0)
- }
-
- // init DebugBuffer
- db := &hotline.DebugBuffer{
- TextView: tview.NewTextView(),
- }
-
- cores := []zapcore.Core{newZapCore(zapLvl, db)}
-
- // Add file logger if optional log-file flag was passed
- if *logFile != "" {
- f, err := os.OpenFile(*logFile,
- os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
- if err != nil {
- log.Println(err)
- }
- defer f.Close()
- if err != nil {
- panic(err)
- }
- cores = append(cores, newZapCore(zapLvl, f))
- }
-
- l := zap.New(zapcore.NewTee(cores...))
- defer func() { _ = l.Sync() }()
- logger := l.Sugar()
- logger.Infow("Started Mobius client", "Version", hotline.VERSION)
-
- go func() {
- sig := <-sigChan
- logger.Infow("Stopping client", "signal", sig.String())
- cancelRoot()
- }()
-
- cfgPath := defaultConfigPath()
-
- client := hotline.NewClient(cfgPath, logger)
- client.DebugBuf = db
- client.UI.Start()
-
-}
-
-func newZapCore(level zapcore.Level, syncer zapcore.WriteSyncer) zapcore.Core {
- encoderCfg := zap.NewProductionEncoderConfig()
- encoderCfg.TimeKey = "timestamp"
- encoderCfg.EncodeTime = zapcore.ISO8601TimeEncoder
-
- return zapcore.NewCore(
- zapcore.NewConsoleEncoder(encoderCfg),
- zapcore.Lock(syncer),
- level,
- )
-}
-
-var zapLogLevel = map[string]zapcore.Level{
- "debug": zap.DebugLevel,
- "info": zap.InfoLevel,
- "warn": zap.WarnLevel,
- "error": zap.ErrorLevel,
-}
-
-func defaultConfigPath() (cfgPath string) {
- os := runtime.GOOS
- switch os {
- case "windows":
- cfgPath = "mobius-client-config.yaml"
- case "darwin":
- cfgPath = "/usr/local/etc/mobius-client-config.yaml"
- case "linux":
- cfgPath = "/usr/local/etc/mobius-client-config.yaml"
- default:
- fmt.Printf("unsupported OS")
- }
-
- return cfgPath
-}
diff --git a/client/mobius-client-config.yaml b/client/mobius-client-config.yaml
deleted file mode 100644
index 978122b..0000000
--- a/client/mobius-client-config.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
-Username: unnamed
-IconID: 414
-Tracker: hltracker.com:5498
-Bookmarks:
- - Name: Example Server
- Addr: localhost:5500
- Login: guest
- Password: "" \ No newline at end of file
diff --git a/client/mobius-hotline-server.service b/client/mobius-hotline-server.service
deleted file mode 100644
index ec2437c..0000000
--- a/client/mobius-hotline-server.service
+++ /dev/null
@@ -1,13 +0,0 @@
-[Unit]
-Description=Mobius Server
-After=network.target
-StartLimitIntervalSec=0
-
-[Service]
-Type=simple
-Restart=always
-RestartSec=1
-ExecStart=/usr/local/bin/mobius-hotline-server
-
-[Install]
-WantedBy=multi-user.target \ No newline at end of file