Files
opencloud/ocis/pkg/command/root.go
Jörn Friedrich Dreyer 066c4b8173 only register signal handling once
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2024-07-29 16:28:13 +02:00

34 lines
710 B
Go

package command
import (
"context"
"os"
"os/signal"
"syscall"
"github.com/owncloud/ocis/v2/ocis-pkg/clihelper"
"github.com/owncloud/ocis/v2/ocis-pkg/config"
"github.com/owncloud/ocis/v2/ocis/pkg/register"
"github.com/urfave/cli/v2"
)
// Execute is the entry point for the ocis command.
func Execute() error {
cfg := config.DefaultConfig()
app := clihelper.DefaultApp(&cli.App{
Name: "ocis",
Usage: "ownCloud Infinite Scale",
})
for _, fn := range register.Commands {
app.Commands = append(
app.Commands,
fn(cfg),
)
}
ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
return app.RunContext(ctx, os.Args)
}