本文整理汇总了Golang中github.com/tsuru/tsuru/provision.App.Log方法的典型用法代码示例。如果您正苦于以下问题:Golang App.Log方法的具体用法?Golang App.Log怎么用?Golang App.Log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tsuru/tsuru/provision.App
的用法示例。
在下文中一共展示了App.Log方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Provision
func (p *JujuProvisioner) Provision(app provision.App) error {
var buf bytes.Buffer
charms, err := config.GetString("juju:charms-path")
if err != nil {
return errors.New(`Setting "juju:charms-path" is not defined.`)
}
args := []string{
"deploy", "--repository", charms,
"local:" + app.GetPlatform(), app.GetName(),
}
err = runCmd(false, &buf, &buf, args...)
out := buf.String()
if err != nil {
app.Log("Failed to create machine: "+out, "tsuru")
return cmdError(out, err, args)
}
setOption := []string{
"set", app.GetName(), "app-repo=" + repository.ReadOnlyURL(app.GetName()),
}
runCmd(true, &buf, &buf, setOption...)
if p.elbSupport() {
router, err := Router()
if err != nil {
return err
}
if err = router.AddBackend(app.GetName()); err != nil {
return err
}
p.enqueueUnits(app.GetName())
}
return nil
}
示例2: Stop
func (p *JujuProvisioner) Stop(app provision.App) error {
var buf bytes.Buffer
err := p.ExecuteCommand(&buf, &buf, app, "/var/lib/tsuru/hooks/stop")
if err != nil {
msg := fmt.Sprintf("Failed to stop the app (%s): %s", err, buf.String())
app.Log(msg, "tsuru-provisioner")
return &provision.Error{Reason: buf.String(), Err: err}
}
return nil
}
示例3: terminateMachines
func (p *JujuProvisioner) terminateMachines(app provision.App, units ...provision.AppUnit) error {
var buf bytes.Buffer
if len(units) < 1 {
units = app.ProvisionedUnits()
}
for _, u := range units {
buf.Reset()
err := runCmd(false, &buf, &buf, "terminate-machine", strconv.Itoa(u.GetMachine()))
out := buf.String()
if err != nil {
msg := fmt.Sprintf("Failed to destroy unit %s: %s", u.GetName(), out)
app.Log(msg, "tsuru")
log.Errorf("Failed to destroy unit %q from the app %q: %s", u.GetName(), app.GetName(), out)
return cmdError(out, err, []string{"terminate-machine", strconv.Itoa(u.GetMachine())})
}
}
return nil
}
示例4: destroyService
func (p *JujuProvisioner) destroyService(app provision.App) error {
var (
err error
buf bytes.Buffer
out string
)
// Sometimes juju gives the "no node" error. This is one of Zookeeper
// bad behaviors. Let's try it multiple times before raising the error
// to the user, and hope that someday we run away from Zookeeper.
for i := 0; i < destroyTries; i++ {
buf.Reset()
err = runCmd(false, &buf, &buf, "destroy-service", app.GetName())
if err == nil {
break
}
out = buf.String()
}
if err != nil {
msg := fmt.Sprintf("Failed to destroy the app: %s.", out)
app.Log(msg, "tsuru")
return cmdError(out, err, []string{"destroy-service", app.GetName()})
}
return nil
}