Windows: Allow running as a service
Signed-off-by: John Howard <jhoward@microsoft.com> Allows containerd.exe to run as a Windows service. eg Register: `.\containerd.exe --register-service` Start: `net start containerd` ... Stop: `net stop containerd` Unregister: `.\containerd.exe --unregister-service` When running as a service, logs will go to the Windows application event log.
This commit is contained in:
@@ -50,23 +50,28 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// New creates and initializes a new containerd server
|
||||
func New(ctx context.Context, config *srvconfig.Config) (*Server, error) {
|
||||
// CreateTopLevelDirectories creates the top-level root and state directories.
|
||||
func CreateTopLevelDirectories(config *srvconfig.Config) error {
|
||||
switch {
|
||||
case config.Root == "":
|
||||
return nil, errors.New("root must be specified")
|
||||
return errors.New("root must be specified")
|
||||
case config.State == "":
|
||||
return nil, errors.New("state must be specified")
|
||||
return errors.New("state must be specified")
|
||||
case config.Root == config.State:
|
||||
return nil, errors.New("root and state must be different paths")
|
||||
return errors.New("root and state must be different paths")
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(config.Root, 0711); err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
if err := os.MkdirAll(config.State, 0711); err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// New creates and initializes a new containerd server
|
||||
func New(ctx context.Context, config *srvconfig.Config) (*Server, error) {
|
||||
if err := apply(ctx, config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user