本文整理汇总了Golang中github.com/cortesi/modd/varcmd.VarCmd类的典型用法代码示例。如果您正苦于以下问题:Golang VarCmd类的具体用法?Golang VarCmd怎么用?Golang VarCmd使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VarCmd类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: NewDaemonPen
// NewDaemonPen creates a new DaemonPen
func NewDaemonPen(block conf.Block, vars map[string]string, log termlog.TermLog) (*DaemonPen, error) {
d := make([]*daemon, len(block.Daemons))
for i, dmn := range block.Daemons {
vcmd := varcmd.VarCmd{Block: nil, Mod: nil, Vars: vars}
finalcmd, err := vcmd.Render(dmn.Command)
if err != nil {
return nil, err
}
dmn.Command = finalcmd
var indir string
if block.InDir != "" {
indir = block.InDir
} else {
indir, err = os.Getwd()
if err != nil {
return nil, err
}
}
d[i] = &daemon{
conf: dmn,
log: log.Stream(niceHeader("daemon: ", dmn.Command)),
shell: vars[shellVarName],
indir: indir,
}
}
return &DaemonPen{daemons: d}, nil
}
开发者ID:cortesi,项目名称:modd,代码行数:29,代码来源:daemon.go
示例2: RunPreps
// RunPreps runs all commands in sequence. Stops if any command returns an error.
func RunPreps(b conf.Block, vars map[string]string, mod *watch.Mod, log termlog.TermLog) error {
vcmd := varcmd.VarCmd{Block: &b, Mod: mod, Vars: vars}
for _, p := range b.Preps {
cmd, err := vcmd.Render(p.Command)
if err != nil {
return err
}
err = RunProc(cmd, log.Stream(niceHeader("prep: ", cmd)))
if err != nil {
return err
}
}
return nil
}
开发者ID:johnjohnsp1,项目名称:modd,代码行数:15,代码来源:proc.go
示例3: NewDaemonPen
// NewDaemonPen creates a new DaemonPen
func NewDaemonPen(block conf.Block, vars map[string]string, log termlog.TermLog) (*DaemonPen, error) {
d := make([]*daemon, len(block.Daemons))
for i, dmn := range block.Daemons {
vcmd := varcmd.VarCmd{Block: nil, Mod: nil, Vars: vars}
finalcmd, err := vcmd.Render(dmn.Command)
if err != nil {
return nil, err
}
dmn.Command = finalcmd
d[i] = &daemon{
conf: dmn,
log: log.Stream(niceHeader("daemon: ", dmn.Command)),
}
}
return &DaemonPen{daemons: d}, nil
}
开发者ID:elfchief,项目名称:modd,代码行数:17,代码来源:daemon.go
示例4: Run
func (d *daemon) Run() {
var lastStart time.Time
for d.stop != true {
d.log.Notice(">> starting...")
since := time.Now().Sub(lastStart)
if since < MinRestart {
time.Sleep(MinRestart - since)
}
lastStart = time.Now()
sh := getShell()
vcmd := varcmd.VarCmd{Block: nil, Mod: nil, Vars: d.vars}
finalcmd, err := vcmd.Render(d.conf.Command)
if err != nil {
d.log.Shout("%s", err)
continue
}
c := exec.Command(sh, "-c", finalcmd)
stdo, err := c.StdoutPipe()
if err != nil {
d.log.Shout("%s", err)
continue
}
stde, err := c.StderrPipe()
if err != nil {
d.log.Shout("%s", err)
continue
}
wg := sync.WaitGroup{}
wg.Add(2)
go logOutput(&wg, stde, d.log.Warn)
go logOutput(&wg, stdo, d.log.Say)
err = c.Start()
if err != nil {
d.log.Shout("%s", err)
continue
}
d.cmd = c
err = c.Wait()
wg.Wait()
if err != nil {
d.log.Shout("%s", c.ProcessState.String())
continue
}
}
}
开发者ID:mattn,项目名称:modd,代码行数:47,代码来源:proc.go
示例5: RunPreps
// RunPreps runs all commands in sequence. Stops if any command returns an error.
func RunPreps(b conf.Block, vars map[string]string, mod *watch.Mod, log termlog.TermLog, notifiers []notify.Notifier) error {
vcmd := varcmd.VarCmd{Block: &b, Mod: mod, Vars: vars}
for _, p := range b.Preps {
cmd, err := vcmd.Render(p.Command)
if err != nil {
return err
}
err = RunProc(cmd, log.Stream(niceHeader("prep: ", cmd)))
if err != nil {
if pe, ok := err.(ProcError); ok {
for _, n := range notifiers {
n.Push("modd error", pe.Output, "")
}
}
return err
}
}
return nil
}
开发者ID:elfchief,项目名称:modd,代码行数:20,代码来源:prep.go
示例6: Start
// Start starts set of daemons, each specified by a command
func (dp *DaemonPen) Start(daemons []conf.Daemon, vars map[string]string, log termlog.TermLog) {
dp.Lock()
defer dp.Unlock()
d := make([]daemon, len(daemons))
for i, dmn := range daemons {
vcmd := varcmd.VarCmd{Block: nil, Mod: nil, Vars: vars}
finalcmd, err := vcmd.Render(dmn.Command)
if err != nil {
log.Shout("%s", err)
continue
}
dmn.Command = finalcmd
d[i] = daemon{
conf: dmn,
log: log.Stream(
niceHeader("daemon: ", dmn.Command),
),
}
go d[i].Run()
}
dp.daemons = &d
}
开发者ID:johnjohnsp1,项目名称:modd,代码行数:23,代码来源:proc.go
示例7: RunPreps
// RunPreps runs all commands in sequence. Stops if any command returns an error.
func RunPreps(b conf.Block, vars map[string]string, mod *moddwatch.Mod, log termlog.TermLog, notifiers []notify.Notifier, initial bool) error {
shell := vars[shellVarName]
vcmd := varcmd.VarCmd{Block: &b, Mod: mod, Vars: vars}
for _, p := range b.Preps {
cmd, err := vcmd.Render(p.Command)
if initial && p.Onchange {
log.Say(niceHeader("skipping prep: ", cmd))
continue
}
if err != nil {
return err
}
err = RunProc(cmd, shell, log.Stream(niceHeader("prep: ", cmd)))
if err != nil {
if pe, ok := err.(ProcError); ok {
for _, n := range notifiers {
n.Push("modd error", pe.Output, "")
}
}
return err
}
}
return nil
}
开发者ID:cortesi,项目名称:modd,代码行数:25,代码来源:prep.go
注:本文中的github.com/cortesi/modd/varcmd.VarCmd类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论