本文整理汇总了Golang中github.com/juju/core/cmd.Context.StopInterruptNotify方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.StopInterruptNotify方法的具体用法?Golang Context.StopInterruptNotify怎么用?Golang Context.StopInterruptNotify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/core/cmd.Context
的用法示例。
在下文中一共展示了Context.StopInterruptNotify方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Run
// Run connects to the environment specified on the command line and bootstraps
// a juju in that environment if none already exists. If there is as yet no environments.yaml file,
// the user is informed how to create one.
func (c *BootstrapCommand) Run(ctx *cmd.Context) (resultErr error) {
bootstrapFuncs := getBootstrapFuncs()
if len(c.seriesOld) > 0 {
fmt.Fprintln(ctx.Stderr, "Use of --series is deprecated. Please use --upload-series instead.")
}
environ, cleanup, err := environFromName(ctx, c.EnvName, &resultErr, "Bootstrap")
if err != nil {
return err
}
// We want to validate constraints early. However, if a custom image metadata
// source is specified, we can't validate the arch because that depends on what
// images metadata is to be uploaded. So we validate here if no custom metadata
// source is specified, and defer till later if not.
if c.MetadataSource == "" {
if err := validateConstraints(c.Constraints, environ); err != nil {
return err
}
}
defer cleanup()
if err := bootstrapFuncs.EnsureNotBootstrapped(environ); err != nil {
return err
}
// Block interruption during bootstrap. Providers may also
// register for interrupt notification so they can exit early.
interrupted := make(chan os.Signal, 1)
defer close(interrupted)
ctx.InterruptNotify(interrupted)
defer ctx.StopInterruptNotify(interrupted)
go func() {
for _ = range interrupted {
ctx.Infof("Interrupt signalled: waiting for bootstrap to exit")
}
}()
// If --metadata-source is specified, override the default tools metadata source so
// SyncTools can use it, and also upload any image metadata.
if c.MetadataSource != "" {
metadataDir := ctx.AbsPath(c.MetadataSource)
if err := uploadCustomMetadata(metadataDir, environ); err != nil {
return err
}
if err := validateConstraints(c.Constraints, environ); err != nil {
return err
}
}
// TODO (wallyworld): 2013-09-20 bug 1227931
// We can set a custom tools data source instead of doing an
// unnecessary upload.
if environ.Config().Type() == provider.Local {
c.UploadTools = true
}
if c.UploadTools {
err = bootstrapFuncs.UploadTools(ctx, environ, c.Constraints.Arch, true, c.Series...)
if err != nil {
return err
}
}
return bootstrapFuncs.Bootstrap(ctx, environ, environs.BootstrapParams{
Constraints: c.Constraints,
Placement: c.Placement,
})
}