This repository has been archived by the owner on Dec 2, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Minor fix. * fix lint errors. * Refactor business logic. * Separate business logic and signaling. - Support custom business logic node. - Add JWT support. * Remove FindNode from islb.proto. * Move the jwt directory to signal. * Move biz(conference server) to /apps. * Add node id to config. * golangci-lint fix. * update. * Support disconnection detection using service discovery. * Update. * Upgrade nats-discovery to v0.3.0. * Improve directory structure. * update. * golangci-lint. * update. * update nats-grpc.
- Loading branch information
1 parent
62cb04f
commit e141bff
Showing
59 changed files
with
2,920 additions
and
1,156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package main | ||
|
||
// ============================================================================ | ||
// GO | ||
// ============================================================================ | ||
// GRPC & Protobuf | ||
//go:generate /usr/bin/env bash -c "echo 'Generating [biz] protobuf and grpc services for Go, outdir=$OUTDIR'" | ||
//go:generate protoc ./proto/biz.proto -I./proto -I../../ --go_opt=module=github.com/pion/ion --go_out=../../$OUTDIR --go-grpc_opt=module=github.com/pion/ion --go-grpc_out=../../$OUTDIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// Package cmd contains an entrypoint for running an ion-sfu instance. | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"os" | ||
|
||
log "github.com/pion/ion-log" | ||
biz "github.com/pion/ion/apps/biz/server" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
var ( | ||
conf = biz.Config{} | ||
file string | ||
) | ||
|
||
func showHelp() { | ||
fmt.Printf("Usage:%s {params}\n", os.Args[0]) | ||
fmt.Println(" -c {config file}") | ||
fmt.Println(" -h (show help info)") | ||
} | ||
|
||
func unmarshal(rawVal interface{}) bool { | ||
if err := viper.Unmarshal(rawVal); err != nil { | ||
fmt.Printf("config file %s loaded failed. %v\n", file, err) | ||
return false | ||
} | ||
return true | ||
} | ||
|
||
func load() bool { | ||
_, err := os.Stat(file) | ||
if err != nil { | ||
return false | ||
} | ||
|
||
viper.SetConfigFile(file) | ||
viper.SetConfigType("toml") | ||
|
||
err = viper.ReadInConfig() | ||
if err != nil { | ||
fmt.Printf("config file %s read failed. %v\n", file, err) | ||
return false | ||
} | ||
|
||
if !unmarshal(&conf) { | ||
return false | ||
} | ||
if err != nil { | ||
fmt.Printf("config file %s loaded failed. %v\n", file, err) | ||
return false | ||
} | ||
|
||
fmt.Printf("config %s load ok!\n", file) | ||
|
||
return true | ||
} | ||
|
||
func parse() bool { | ||
flag.StringVar(&file, "c", "configs/biz.toml", "config file") | ||
help := flag.Bool("h", false, "help info") | ||
flag.Parse() | ||
if !load() { | ||
return false | ||
} | ||
|
||
if *help { | ||
showHelp() | ||
return false | ||
} | ||
return true | ||
} | ||
|
||
func main() { | ||
if !parse() { | ||
showHelp() | ||
os.Exit(-1) | ||
} | ||
log.Init(conf.Log.Level) | ||
log.Infof("--- Starting Biz Node ---") | ||
node := biz.NewBIZ(conf.Node.NID) | ||
if err := node.Start(conf); err != nil { | ||
log.Errorf("biz init start: %v", err) | ||
os.Exit(-1) | ||
} | ||
defer node.Close() | ||
select {} | ||
} |
Oops, something went wrong.