本文整理汇总了Golang中github.com/tsuru/tsuru/log.Write函数的典型用法代码示例。如果您正苦于以下问题:Golang Write函数的具体用法?Golang Write怎么用?Golang Write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Write函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Git
func Git(provisioner provision.Provisioner, app provision.App, objID string, w io.Writer) error {
log.Write(w, []byte("\n ---> tsuru receiving push\n"))
log.Write(w, []byte("\n ---> Replicating the application repository across units\n"))
out, err := clone(provisioner, app)
if err != nil {
out, err = fetch(provisioner, app)
}
if err != nil {
msg := fmt.Sprintf("Got error while cloning/fetching repository: %s -- \n%s", err, string(out))
log.Write(w, []byte(msg))
return errors.New(msg)
}
out, err = checkout(provisioner, app, objID)
if err != nil {
msg := fmt.Sprintf("Failed to checkout Git repository: %s -- \n%s", err, string(out))
log.Write(w, []byte(msg))
return errors.New(msg)
}
log.Write(w, []byte("\n ---> Installing dependencies\n"))
if err := provisioner.InstallDeps(app, w); err != nil {
log.Write(w, []byte(err.Error()))
return err
}
log.Write(w, []byte("\n ---> Restarting application\n"))
if err := app.Restart(w); err != nil {
log.Write(w, []byte(err.Error()))
return err
}
return log.Write(w, []byte("\n ---> Deploy done!\n\n"))
}
示例2: Stop
func (app *App) Stop(w io.Writer) error {
log.Write(w, []byte("\n ---> Stopping your app\n"))
err := Provisioner.Stop(app)
if err != nil {
log.Errorf("[stop] error on stop the app %s - %s", app.Name, err)
return err
}
return nil
}
示例3: Stop
func (app *App) Stop(w io.Writer, process string) error {
msg := fmt.Sprintf("\n ---> Stopping the process %q\n", process)
if process == "" {
msg = fmt.Sprintf("\n ---> Stopping the app %q\n", app.Name)
}
log.Write(w, []byte(msg))
err := Provisioner.Stop(app, process)
if err != nil {
log.Errorf("[stop] error on stop the app %s - %s", app.Name, err)
return err
}
return nil
}
示例4: Restart
// Restart runs the restart hook for the app, writing its output to w.
func (app *App) Restart(process string, w io.Writer) error {
msg := fmt.Sprintf("---- Restarting process %q ----\n", process)
if process == "" {
msg = fmt.Sprintf("---- Restarting the app %q ----\n", app.Name)
}
err := log.Write(w, []byte(msg))
if err != nil {
log.Errorf("[restart] error on write app log for the app %s - %s", app.Name, err)
return err
}
err = Provisioner.Restart(app, process, w)
if err != nil {
log.Errorf("[restart] error on restart the app %s - %s", app.Name, err)
return err
}
return nil
}
示例5: Restart
// Restart runs the restart hook for the app, writing its output to w.
func (app *App) Restart(w io.Writer) error {
err := app.hookRunner().Restart(app, w, "before")
if err != nil {
return err
}
err = log.Write(w, []byte("\n ---> Restarting your app\n"))
if err != nil {
log.Errorf("[restart] error on write app log for the app %s - %s", app.Name, err)
return err
}
err = Provisioner.Restart(app)
if err != nil {
log.Errorf("[restart] error on restart the app %s - %s", app.Name, err)
return err
}
return app.hookRunner().Restart(app, w, "after")
}
示例6: Start
// Start starts the app calling the provisioner.Start method and
// changing the units state to StatusStarted.
func (app *App) Start(w io.Writer, process string) error {
msg := fmt.Sprintf("\n ---> Starting the process %q\n", process)
if process == "" {
msg = fmt.Sprintf("\n ---> Starting the app %q\n", app.Name)
}
log.Write(w, []byte(msg))
err := Provisioner.Start(app, process)
if err != nil {
log.Errorf("[start] error on start the app %s - %s", app.Name, err)
return err
}
_, err = app.RebuildRoutes()
if err != nil {
return err
}
return nil
}
示例7: Start
// Start starts the app calling the provisioner.Start method and
// changing the units state to StatusStarted.
func (app *App) Start(w io.Writer, process string) error {
msg := fmt.Sprintf("\n ---> Starting the process %q\n", process)
if process == "" {
msg = fmt.Sprintf("\n ---> Starting the app %q\n", app.Name)
}
log.Write(w, []byte(msg))
prov, err := app.getProvisioner()
if err != nil {
return err
}
err = prov.Start(app, process)
if err != nil {
log.Errorf("[start] error on start the app %s - %s", app.Name, err)
return err
}
rebuild.RoutesRebuildOrEnqueue(app.Name)
return err
}
示例8: Sleep
func (app *App) Sleep(w io.Writer, process string, proxyURL *url.URL) error {
prov, err := app.getProvisioner()
if err != nil {
return err
}
sleepProv, ok := prov.(provision.SleepableProvisioner)
if !ok {
return provision.ProvisionerNotSupported{Prov: prov, Action: "sleeping"}
}
msg := fmt.Sprintf("\n ---> Putting the process %q to sleep\n", process)
if process == "" {
msg = fmt.Sprintf("\n ---> Putting the app %q to sleep\n", app.Name)
}
log.Write(w, []byte(msg))
r, err := app.Router()
if err != nil {
log.Errorf("[sleep] error on sleep the app %s - %s", app.Name, err)
return err
}
oldRoutes, err := r.Routes(app.GetName())
if err != nil {
log.Errorf("[sleep] error on sleep the app %s - %s", app.Name, err)
return err
}
for _, route := range oldRoutes {
r.RemoveRoute(app.GetName(), route)
}
err = r.AddRoute(app.GetName(), proxyURL)
if err != nil {
log.Errorf("[sleep] error on sleep the app %s - %s", app.Name, err)
return err
}
err = sleepProv.Sleep(app, process)
if err != nil {
log.Errorf("[sleep] error on sleep the app %s - %s", app.Name, err)
for _, route := range oldRoutes {
r.AddRoute(app.GetName(), route)
}
r.RemoveRoute(app.GetName(), proxyURL)
log.Errorf("[sleep] rolling back the sleep %s", app.Name)
return err
}
return nil
}
示例9: Stop
func (app *App) Stop(w io.Writer) error {
log.Write(w, []byte("\n ---> Stopping your app\n"))
err := Provisioner.Stop(app)
if err != nil {
log.Errorf("[stop] error on stop the app %s - %s", app.Name, err)
return err
}
units := make([]Unit, len(app.Units))
for i, u := range app.Units {
u.State = provision.StatusStopped.String()
units[i] = u
}
app.Units = units
conn, err := db.Conn()
if err != nil {
return err
}
defer conn.Close()
return conn.Apps().Update(bson.M{"name": app.Name}, app)
}
示例10: Sleep
func (app *App) Sleep(w io.Writer, process string, proxyURL *url.URL) error {
msg := fmt.Sprintf("\n ---> Putting the process %q to sleep\n", process)
if process == "" {
msg = fmt.Sprintf("\n ---> Putting the app %q to sleep\n", app.Name)
}
log.Write(w, []byte(msg))
routerName, err := app.GetRouter()
if err != nil {
log.Errorf("[sleep] error on sleep the app %s - %s", app.Name, err)
return err
}
r, err := router.Get(routerName)
if err != nil {
log.Errorf("[sleep] error on sleep the app %s - %s", app.Name, err)
return err
}
oldRoutes, err := r.Routes(app.GetName())
if err != nil {
log.Errorf("[sleep] error on sleep the app %s - %s", app.Name, err)
return err
}
for _, route := range oldRoutes {
r.RemoveRoute(app.GetName(), route)
}
err = r.AddRoute(app.GetName(), proxyURL)
if err != nil {
log.Errorf("[sleep] error on sleep the app %s - %s", app.Name, err)
return err
}
err = Provisioner.Sleep(app, process)
if err != nil {
log.Errorf("[sleep] error on sleep the app %s - %s", app.Name, err)
for _, route := range oldRoutes {
r.AddRoute(app.GetName(), route)
}
r.RemoveRoute(app.GetName(), proxyURL)
log.Errorf("[sleep] rolling back the sleep %s", app.Name)
return err
}
return nil
}