func New() *App { var err error log.SetFlags(0) app := &App{ App: core.NewApp("sarif", "tars"), } app.Init() app.Client, err = app.ClientDial(sarif.ClientInfo{ Name: "tars/" + sarif.GenerateId(), Auth: *authString, }) app.Must(err) app.Config.HistoryFile = app.App.Config.Dir() + "/tars_history" app.App.Config.Get("tars", &app.Config) app.Commands = []Command{ {"help", app.Help, ""}, {"interactive", app.Interactive, ""}, {"location_import", app.LocationImport, ""}, {"cat", app.Cat, usageCat}, {"down", app.Down, ""}, {"up", app.Up, ""}, {"edit", app.Edit, ""}, } return app }
func watch() { app := core.NewApp("sarif", "tars") app.Init() info := Cache{FilePath: app.Config.Dir() + "/soji.json"} info.Bars = make(map[string]Bar) info.Read() err := info.Read() if err == nil { if info.PID > 0 { var p *os.Process p, err = os.FindProcess(info.PID) if err == nil { err = p.Signal(syscall.Signal(0)) } } else { err = errors.New("PID not found") } } if err != nil { fork(app) return } mode := "" if *isTmux { mode = "tmux" } keys := make([]string, 0, len(info.Bars)) if len(flag.Args()) > 0 { keys = flag.Args() } else { for key := range info.Bars { keys = append(keys, key) } sort.Strings(keys) } texts := make([]string, 0) for _, key := range keys { bar, ok := info.Bars[key] if !ok { continue } text := bar.PrettyString(mode) if text != "" { texts = append(texts, text) } } fmt.Println(strings.Join(texts, *delimiter)) }
func New(appName, moduleName string) *Server { if moduleName == "" { moduleName = "server" } app := core.NewApp(appName, moduleName) s := &Server{ App: app, } s.ModuleManager = services.NewModuleManager(s.instantiate) if n, err := os.Hostname(); err == nil { s.ServerConfig.Name = n } return s }
func relay() { app := core.NewApp("sarif", "tars") app.Init() info := Cache{FilePath: app.Config.Dir() + "/soji.json"} info.Bars = make(map[string]Bar) info.Read() info.PID = os.Getpid() app.Must(info.Write()) c, err := app.ClientDial(sarif.ClientInfo{ Name: "soji/" + sarif.GenerateId(), }) c.HandleConcurrent = false app.Must(err) c.Subscribe("status", "", func(msg sarif.Message) { key := msg.Action if strings.HasPrefix(key, "status/") { key = strings.TrimPrefix(key, "status/") } else { key = "default" } bar := Bar{Key: key, Label: key, Text: msg.Text} if err := msg.DecodePayload(&bar); err != nil { msg.DecodePayload(&bar.Text) msg.DecodePayload(&bar.Value) } info.Bars[bar.Key] = bar app.Must(info.Write()) }) fmt.Println(os.Getpid()) core.WaitUntilInterrupt() info.PID = 0 app.Must(info.Write()) c.Publish(sarif.CreateMessage("soji/down", nil)) }
func New() *WebClient { app := core.NewApp("sarif", "client") return &WebClient{ app, } }