Skip to content

Commit

Permalink
add import/export feature
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmonsays committed Jan 19, 2016
1 parent ad94097 commit 076f21f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
43 changes: 43 additions & 0 deletions cmd/runitcmd/import.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package main

import (
"github.com/sigmonsays/runitcmd/runit"

"github.com/codegangsta/cli"
)

func initImport(app *Application) cli.Command {
description := "import service"
usage := "import service"

flags := []cli.Flag{}

cmd := cli.Command{
Name: "import",
Usage: usage,
Description: description,
Flags: flags,
Action: app.Import,
}
return cmd
}

func (app *Application) Import(c *cli.Context) {
filenames := c.Args()

for _, filename := range filenames {
cfg := &runit.ServiceConfig{}
err := cfg.LoadFile(filename)
if err != nil {
log.Warnf("import %s: %s", filename, err)
continue
}

err = app.Runit.Apply(cfg)
if err != nil {
log.Warnf("apply %s: %s", cfg.Name, err)
continue
}

}
}
1 change: 1 addition & 0 deletions cmd/runitcmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func main() {
initCreate(app),
initApply(app),
initStatus(app),
initImport(app),
initExport(app),

// more commands
Expand Down
2 changes: 1 addition & 1 deletion runit/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (runit *Runit) Apply(cfg *ServiceConfig) error {
return err
}
}
if cfg.Activated == false {
if cfg.Activated {

err = runit.Activate(sv.Name)
if err != nil {
Expand Down

0 comments on commit 076f21f

Please sign in to comment.