• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang log.Write函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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"))
}
开发者ID:rochacon,项目名称:tsuru,代码行数:30,代码来源:git.go


示例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
}
开发者ID:philiptzou,项目名称:tsuru,代码行数:9,代码来源:app.go


示例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
}
开发者ID:Zapelini,项目名称:tsuru,代码行数:13,代码来源:app.go


示例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
}
开发者ID:Zapelini,项目名称:tsuru,代码行数:18,代码来源:app.go


示例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")
}
开发者ID:philiptzou,项目名称:tsuru,代码行数:18,代码来源:app.go


示例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
}
开发者ID:botvs,项目名称:tsuru,代码行数:19,代码来源:app.go


示例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
}
开发者ID:tsuru,项目名称:tsuru,代码行数:20,代码来源:app.go


示例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
}
开发者ID:tsuru,项目名称:tsuru,代码行数:44,代码来源:app.go


示例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)
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:20,代码来源:app.go


示例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
}
开发者ID:botvs,项目名称:tsuru,代码行数:41,代码来源:app.go



注:本文中的github.com/tsuru/tsuru/log.Write函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang net.URLToHost函数代码示例发布时间:2022-05-28
下一篇:
Golang log.WrapError函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap