first commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/micro/cli"
|
||||
"github.com/owncloud/ocis-hello/pkg/version"
|
||||
)
|
||||
|
||||
// Execute is the entry point for the ocis-accounts command.
|
||||
func Execute() error {
|
||||
|
||||
app := &cli.App{
|
||||
Name: "ocis-accounts",
|
||||
Version: version.String,
|
||||
Usage: "Example service for Reva/oCIS",
|
||||
|
||||
Authors: []cli.Author{
|
||||
{
|
||||
Name: "ownCloud GmbH",
|
||||
Email: "support@owncloud.com",
|
||||
},
|
||||
},
|
||||
|
||||
Commands: []cli.Command{
|
||||
Server(),
|
||||
},
|
||||
}
|
||||
|
||||
cli.HelpFlag = &cli.BoolFlag{
|
||||
Name: "help,h",
|
||||
Usage: "Show the help",
|
||||
}
|
||||
|
||||
cli.VersionFlag = &cli.BoolFlag{
|
||||
Name: "version,v",
|
||||
Usage: "Print the version",
|
||||
}
|
||||
|
||||
return app.Run(os.Args)
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"syscall"
|
||||
|
||||
"github.com/micro/cli"
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis-accounts/pkg/micro/grpc"
|
||||
)
|
||||
|
||||
// Server is the entry point for the server command.
|
||||
func Server() cli.Command {
|
||||
return cli.Command{
|
||||
Name: "server",
|
||||
Usage: "Start accounts service",
|
||||
Action: func(c *cli.Context) error {
|
||||
gr := run.Group{}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
defer cancel()
|
||||
service := grpc.NewService(ctx)
|
||||
|
||||
gr.Add(func() error {
|
||||
return service.Run()
|
||||
}, func(_ error) {
|
||||
|
||||
fmt.Println("shutting down grpc server")
|
||||
cancel()
|
||||
})
|
||||
|
||||
run.SignalHandler(ctx, syscall.SIGKILL)
|
||||
return gr.Run()
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user