feature: Adds more commands and adds an example.

This commit is contained in:
greysoh 2024-12-01 22:07:10 -05:00
parent 0d0f16174b
commit 3cb9526716
Signed by: imterah
GPG key ID: 8FA7DD57BA6CEA37
9 changed files with 352 additions and 41 deletions

View file

@ -33,23 +33,25 @@ func main() {
tempDir, err := os.MkdirTemp("", "nextnet-sockets-")
logLevel := os.Getenv("NEXTNET_LOG_LEVEL")
if logLevel != "" {
switch logLevel {
case "debug":
log.SetLevel(log.DebugLevel)
if logLevel == "" {
logLevel = "fatal"
}
case "info":
log.SetLevel(log.InfoLevel)
switch logLevel {
case "debug":
log.SetLevel(log.DebugLevel)
case "warn":
log.SetLevel(log.WarnLevel)
case "info":
log.SetLevel(log.InfoLevel)
case "error":
log.SetLevel(log.ErrorLevel)
case "warn":
log.SetLevel(log.WarnLevel)
case "fatal":
log.SetLevel(log.FatalLevel)
}
case "error":
log.SetLevel(log.ErrorLevel)
case "fatal":
log.SetLevel(log.FatalLevel)
}
if len(os.Args) != 3 {
@ -109,8 +111,9 @@ func main() {
for {
log.Info("starting process...")
// TODO: can we reuse cmd?
cmd := exec.Command(executablePath)
cmd.Env = append(cmd.Env, fmt.Sprintf("NEXTNET_API_SOCK=%s", sockPath))
cmd.Env = append(cmd.Env, fmt.Sprintf("NEXTNET_API_SOCK=%s", sockPath), fmt.Sprintf("NEXTNET_LOG_LEVEL=%s", logLevel))
cmd.Stdout = stdout
cmd.Stderr = stderr