本文整理匯總了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
}