add storage-home
This commit is contained in:
@@ -50,7 +50,7 @@ var (
|
|||||||
"storage-groupprovider", // done
|
"storage-groupprovider", // done
|
||||||
"storage-auth-basic", // done
|
"storage-auth-basic", // done
|
||||||
"storage-auth-bearer", // done
|
"storage-auth-bearer", // done
|
||||||
"storage-home",
|
"storage-home", // done
|
||||||
"storage-users",
|
"storage-users",
|
||||||
"storage-public-link",
|
"storage-public-link",
|
||||||
"thumbnails", // done
|
"thumbnails", // done
|
||||||
@@ -133,6 +133,7 @@ func (r *Runtime) Start() error {
|
|||||||
addServiceToken("groupsprovider", supervisor.Add(storage.NewGroupsProvider(globalCtx, r.c.Storage))) // TODO(refs) panic? are we sending to a nil / closed channel?
|
addServiceToken("groupsprovider", supervisor.Add(storage.NewGroupsProvider(globalCtx, r.c.Storage))) // TODO(refs) panic? are we sending to a nil / closed channel?
|
||||||
addServiceToken("authbasic", supervisor.Add(storage.NewAuthBasic(globalCtx, r.c.Storage)))
|
addServiceToken("authbasic", supervisor.Add(storage.NewAuthBasic(globalCtx, r.c.Storage)))
|
||||||
addServiceToken("authbearer", supervisor.Add(storage.NewAuthBearer(globalCtx, r.c.Storage)))
|
addServiceToken("authbearer", supervisor.Add(storage.NewAuthBearer(globalCtx, r.c.Storage)))
|
||||||
|
addServiceToken("storage-home", supervisor.Add(storage.NewStorageHome(globalCtx, r.c.Storage)))
|
||||||
|
|
||||||
// TODO(refs) debug line with supervised services.
|
// TODO(refs) debug line with supervised services.
|
||||||
go supervisor.ServeBackground()
|
go supervisor.ServeBackground()
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package command
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"flag"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path"
|
"path"
|
||||||
@@ -197,3 +198,43 @@ func StorageHome(cfg *config.Config) *cli.Command {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StorageHomeSutureService allows for the storage-home command to be embedded and supervised by a suture supervisor tree.
|
||||||
|
type StorageHomeSutureService struct {
|
||||||
|
ctx context.Context
|
||||||
|
cancel context.CancelFunc // used to cancel the context go-micro services used to shutdown a service.
|
||||||
|
cfg *config.Config
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewStorageHomeSutureService creates a new storage.StorageHomeSutureService
|
||||||
|
func NewStorageHome(ctx context.Context, cfg *config.Config) StorageHomeSutureService {
|
||||||
|
sctx, cancel := context.WithCancel(ctx)
|
||||||
|
cfg.Context = sctx
|
||||||
|
return StorageHomeSutureService{
|
||||||
|
ctx: sctx,
|
||||||
|
cancel: cancel,
|
||||||
|
cfg: cfg,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s StorageHomeSutureService) Serve() {
|
||||||
|
f := &flag.FlagSet{}
|
||||||
|
for k := range StorageHome(s.cfg).Flags {
|
||||||
|
if err := StorageHome(s.cfg).Flags[k].Apply(f); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx := cli.NewContext(nil, f, nil)
|
||||||
|
if StorageHome(s.cfg).Before != nil {
|
||||||
|
if err := StorageHome(s.cfg).Before(ctx); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := StorageHome(s.cfg).Action(ctx); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s StorageHomeSutureService) Stop() {
|
||||||
|
s.cancel()
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user