Be more like a library to support mobile (#247)

This commit is contained in:
Nathan Brown
2020-06-30 13:48:58 -05:00
committed by GitHub
parent 1ea8847085
commit 41578ca971
21 changed files with 477 additions and 69 deletions

View File

@ -3,9 +3,9 @@ package main
import (
"flag"
"fmt"
"os"
"github.com/sirupsen/logrus"
"github.com/slackhq/nebula"
"os"
)
// A version string that can be set with
@ -45,5 +45,25 @@ func main() {
os.Exit(1)
}
nebula.Main(*configPath, *configTest, Build)
config := nebula.NewConfig()
err := config.Load(*configPath)
if err != nil {
fmt.Printf("failed to load config: %s", err)
os.Exit(1)
}
l := logrus.New()
l.Out = os.Stdout
err = nebula.Main(config, *configTest, true, Build, l, nil, nil)
switch v := err.(type) {
case nebula.ContextualError:
v.Log(l)
os.Exit(1)
case error:
l.WithError(err).Error("Failed to start")
os.Exit(1)
}
os.Exit(0)
}

View File

@ -1,6 +1,8 @@
package main
import (
"fmt"
"github.com/sirupsen/logrus"
"log"
"os"
"path/filepath"
@ -27,8 +29,15 @@ func (p *program) Start(s service.Service) error {
}
func (p *program) run() error {
nebula.Main(*p.configPath, *p.configTest, Build)
return nil
config := nebula.NewConfig()
err := config.Load(*p.configPath)
if err != nil {
return fmt.Errorf("failed to load config: %s", err)
}
l := logrus.New()
l.Out = os.Stdout
return nebula.Main(config, *p.configTest, true, Build, l, nil, nil)
}
func (p *program) Stop(s service.Service) error {

View File

@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"github.com/sirupsen/logrus"
"os"
"github.com/slackhq/nebula"
@ -39,5 +40,25 @@ func main() {
os.Exit(1)
}
nebula.Main(*configPath, *configTest, Build)
config := nebula.NewConfig()
err := config.Load(*configPath)
if err != nil {
fmt.Printf("failed to load config: %s", err)
os.Exit(1)
}
l := logrus.New()
l.Out = os.Stdout
err = nebula.Main(config, *configTest, true, Build, l, nil, nil)
switch v := err.(type) {
case nebula.ContextualError:
v.Log(l)
os.Exit(1)
case error:
l.WithError(err).Error("Failed to start")
os.Exit(1)
}
os.Exit(0)
}