本文整理汇总了Golang中github.com/convox/rack/cmd/convox/stdcli.ExitError函数的典型用法代码示例。如果您正苦于以下问题:Golang ExitError函数的具体用法?Golang ExitError怎么用?Golang ExitError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ExitError函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: cmdRackUpdate
func cmdRackUpdate(c *cli.Context) error {
versions, err := version.All()
if err != nil {
return stdcli.ExitError(err)
}
specified := "stable"
if len(c.Args()) > 0 {
specified = c.Args()[0]
}
version, err := versions.Resolve(specified)
if err != nil {
return stdcli.ExitError(err)
}
system, err := rackClient(c).UpdateSystem(version.Version)
if err != nil {
return stdcli.ExitError(err)
}
fmt.Printf("Name %s\n", system.Name)
fmt.Printf("Status %s\n", system.Status)
fmt.Printf("Version %s\n", system.Version)
fmt.Printf("Count %d\n", system.Count)
fmt.Printf("Type %s\n", system.Type)
fmt.Println()
fmt.Printf("Updating to version: %s\n", version.Version)
return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:32,代码来源:rack.go
示例2: cmdAppParams
func cmdAppParams(c *cli.Context) error {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
return stdcli.ExitError(err)
}
params, err := rackClient(c).ListParameters(app)
if err != nil {
return stdcli.ExitError(err)
}
keys := []string{}
for key, _ := range params {
keys = append(keys, key)
}
sort.Strings(keys)
t := stdcli.NewTable("NAME", "VALUE")
for _, key := range keys {
t.AddRow(key, params[key])
}
t.Print()
return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:28,代码来源:apps.go
示例3: cmdRun
func cmdRun(c *cli.Context) error {
if c.Bool("detach") {
return cmdRunDetached(c)
}
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
return stdcli.ExitError(err)
}
if len(c.Args()) < 2 {
stdcli.Usage(c, "run")
return nil
}
ps := c.Args()[0]
err = validateProcessId(c, app, ps)
if err != nil {
return stdcli.ExitError(err)
}
args := strings.Join(c.Args()[1:], " ")
release := c.String("release")
code, err := runAttached(c, app, ps, args, release)
if err != nil {
return stdcli.ExitError(err)
}
return cli.NewExitError("", code)
}
开发者ID:gmelika,项目名称:rack,代码行数:32,代码来源:run.go
示例4: cmdAppParamsSet
func cmdAppParamsSet(c *cli.Context) error {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
return stdcli.ExitError(err)
}
params := map[string]string{}
for _, arg := range c.Args() {
parts := strings.SplitN(arg, "=", 2)
if len(parts) != 2 {
return stdcli.ExitError(fmt.Errorf("invalid argument: %s", arg))
}
params[parts[0]] = parts[1]
}
fmt.Print("Updating parameters... ")
err = rackClient(c).SetParameters(app, params)
if err != nil {
return stdcli.ExitError(err)
}
fmt.Println("OK")
return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:28,代码来源:apps.go
示例5: cmdSSLList
func cmdSSLList(c *cli.Context) error {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
return stdcli.ExitError(err)
}
if len(c.Args()) > 0 {
return stdcli.ExitError(fmt.Errorf("`convox ssl` does not take arguments. Perhaps you meant `convox ssl update`?"))
}
if c.Bool("help") {
stdcli.Usage(c, "")
return nil
}
ssls, err := rackClient(c).ListSSL(app)
if err != nil {
return stdcli.ExitError(err)
}
t := stdcli.NewTable("TARGET", "CERTIFICATE", "DOMAIN", "EXPIRES")
for _, ssl := range *ssls {
t.AddRow(fmt.Sprintf("%s:%d", ssl.Process, ssl.Port), ssl.Certificate, ssl.Domain, humanizeTime(ssl.Expiration))
}
t.Print()
return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:29,代码来源:ssl.go
示例6: cmdReleasePromote
func cmdReleasePromote(c *cli.Context) error {
if len(c.Args()) < 1 {
stdcli.Usage(c, "releases promote")
return nil
}
release := c.Args()[0]
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
return stdcli.ExitError(err)
}
fmt.Printf("Promoting %s... ", release)
_, err = rackClient(c).PromoteRelease(app, release)
if err != nil {
return stdcli.ExitError(err)
}
fmt.Println("UPDATING")
if c.Bool("wait") {
fmt.Printf("Waiting for stabilization... ")
if err := waitForReleasePromotion(c, app, release); err != nil {
return stdcli.ExitError(err)
}
fmt.Println("OK")
}
return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:34,代码来源:releases.go
示例7: cmdServiceURL
func cmdServiceURL(c *cli.Context) error {
if len(c.Args()) != 1 {
stdcli.Usage(c, "url")
return nil
}
name := c.Args()[0]
service, err := rackClient(c).GetService(name)
if err != nil {
return stdcli.ExitError(err)
}
if service.Status == "failed" {
return stdcli.ExitError(fmt.Errorf("Service failure for %s", service.StatusReason))
}
if service.URL == "" {
return stdcli.ExitError(fmt.Errorf("URL does not exist for %s", service.Name))
}
fmt.Printf("%s\n", service.URL)
return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:25,代码来源:services.go
示例8: cmdAppCreate
func cmdAppCreate(c *cli.Context) error {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
return stdcli.ExitError(err)
}
if len(c.Args()) > 0 {
app = c.Args()[0]
}
if app == "" {
return stdcli.ExitError(fmt.Errorf("must specify an app name"))
}
fmt.Printf("Creating app %s... ", app)
_, err = rackClient(c).CreateApp(app)
if err != nil {
return stdcli.ExitError(err)
}
fmt.Println("CREATING")
if c.Bool("wait") {
fmt.Printf("Waiting for %s... ", app)
if err := waitForAppRunning(c, app); err != nil {
stdcli.ExitError(err)
}
fmt.Println("OK")
}
return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:35,代码来源:apps.go
示例9: cmdLogin
func cmdLogin(c *cli.Context) error {
var host string
if len(c.Args()) < 1 {
host = "console.convox.com"
} else {
host = c.Args()[0]
}
u, err := url.Parse(host)
if err != nil {
return stdcli.ExitError(err)
}
if u.Host != "" {
host = u.Host
}
password := os.Getenv("CONVOX_PASSWORD")
if password == "" {
password = c.String("password")
}
if password != "" {
// password flag
err = testLogin(host, password, c.App.Version)
} else {
// first try current login
password, err = getLogin(host)
err = testLogin(host, password, c.App.Version)
// then prompt for password
if err != nil {
password = promptForPassword()
err = testLogin(host, password, c.App.Version)
}
}
if err != nil {
if strings.Contains(err.Error(), "401") {
return stdcli.ExitError(fmt.Errorf("invalid login"))
} else {
return stdcli.ExitError(err)
}
}
err = addLogin(host, password)
if err != nil {
return stdcli.ExitError(err)
}
err = switchHost(host)
if err != nil {
return stdcli.ExitError(err)
}
fmt.Println("Logged in successfully.")
return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:60,代码来源:login.go
示例10: cmdEnvList
func cmdEnvList(c *cli.Context) error {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
return stdcli.ExitError(err)
}
if len(c.Args()) > 0 {
return stdcli.ExitError(fmt.Errorf("`convox env` does not take arguments. Perhaps you meant `convox env set`?"))
}
if c.Bool("help") {
stdcli.Usage(c, "")
return nil
}
env, err := rackClient(c).GetEnvironment(app)
if err != nil {
return stdcli.ExitError(err)
}
keys := []string{}
for key, _ := range env {
keys = append(keys, key)
}
sort.Strings(keys)
for _, key := range keys {
fmt.Printf("%s=%s\n", key, env[key])
}
return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:34,代码来源:env.go
示例11: cmdReleaseInfo
func cmdReleaseInfo(c *cli.Context) error {
if len(c.Args()) < 1 {
stdcli.Usage(c, "release info")
return nil
}
release := c.Args()[0]
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
return stdcli.ExitError(err)
}
r, err := rackClient(c).GetRelease(app, release)
if err != nil {
return stdcli.ExitError(err)
}
fmt.Printf("Id %s\n", r.Id)
fmt.Printf("Build %s\n", r.Build)
fmt.Printf("Created %s\n", r.Created)
fmt.Printf("Env ")
fmt.Println(strings.Replace(r.Env, "\n", "\n ", -1))
return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:26,代码来源:releases.go
示例12: cmdRackPs
func cmdRackPs(c *cli.Context) error {
system, err := rackClient(c).GetSystem()
if err != nil {
return stdcli.ExitError(err)
}
ps, err := rackClient(c).GetProcesses(system.Name, c.Bool("stats"))
if err != nil {
return stdcli.ExitError(err)
}
if c.Bool("stats") {
fm, err := rackClient(c).ListFormation(system.Name)
if err != nil {
return stdcli.ExitError(err)
}
displayProcessesStats(ps, fm)
return nil
}
displayProcesses(ps)
return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:25,代码来源:rack.go
示例13: cmdSSLUpdate
func cmdSSLUpdate(c *cli.Context) error {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
return stdcli.ExitError(err)
}
if len(c.Args()) < 2 {
stdcli.Usage(c, "update")
return nil
}
target := c.Args()[0]
parts := strings.Split(target, ":")
if len(parts) != 2 {
return stdcli.ExitError(fmt.Errorf("target must be process:port"))
}
fmt.Printf("Updating certificate... ")
_, err = rackClient(c).UpdateSSL(app, parts[0], parts[1], c.Args()[1])
if err != nil {
return stdcli.ExitError(err)
}
fmt.Println("OK")
return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:29,代码来源:ssl.go
示例14: cmdRackParams
func cmdRackParams(c *cli.Context) error {
system, err := rackClient(c).GetSystem()
if err != nil {
return stdcli.ExitError(err)
}
params, err := rackClient(c).ListParameters(system.Name)
if err != nil {
return stdcli.ExitError(err)
}
keys := []string{}
for key, _ := range params {
keys = append(keys, key)
}
sort.Strings(keys)
t := stdcli.NewTable("NAME", "VALUE")
for _, key := range keys {
t.AddRow(key, params[key])
}
t.Print()
return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:28,代码来源:rack.go
示例15: cmdInstancesList
func cmdInstancesList(c *cli.Context) error {
if len(c.Args()) > 0 {
return stdcli.ExitError(fmt.Errorf("`convox instances` does not take arguments. Perhaps you meant `convox instances ssh`?"))
}
if c.Bool("help") {
stdcli.Usage(c, "")
return nil
}
instances, err := rackClient(c).GetInstances()
if err != nil {
return stdcli.ExitError(err)
}
t := stdcli.NewTable("ID", "AGENT", "STATUS", "STARTED", "PS", "CPU", "MEM")
for _, i := range instances {
agent := "off"
if i.Agent {
agent = "on"
}
t.AddRow(i.Id, agent, i.Status,
humanizeTime(i.Started),
strconv.Itoa(i.Processes),
fmt.Sprintf("%0.2f%%", i.Cpu*100),
fmt.Sprintf("%0.2f%%", i.Memory*100))
}
t.Print()
return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:33,代码来源:instances.go
示例16: cmdPsInfo
func cmdPsInfo(c *cli.Context) error {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
return stdcli.ExitError(err)
}
if len(c.Args()) != 1 {
stdcli.Usage(c, "info")
return nil
}
id := c.Args()[0]
p, err := rackClient(c).GetProcess(app, id)
if err != nil {
return stdcli.ExitError(err)
}
fmt.Printf("Id %s\n", p.Id)
fmt.Printf("Name %s\n", p.Name)
fmt.Printf("Release %s\n", p.Release)
fmt.Printf("CPU %0.2f%%\n", p.Cpu)
fmt.Printf("Memory %0.2f%%\n", p.Memory*100)
fmt.Printf("Started %s\n", humanizeTime(p.Started))
fmt.Printf("Command %s\n", p.Command)
return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:28,代码来源:ps.go
示例17: cmdPs
func cmdPs(c *cli.Context) error {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
return stdcli.ExitError(err)
}
ps, err := rackClient(c).GetProcesses(app, c.Bool("stats"))
if err != nil {
return stdcli.ExitError(err)
}
if c.Bool("stats") {
fm, err := rackClient(c).ListFormation(app)
if err != nil {
return stdcli.ExitError(err)
}
displayProcessesStats(ps, fm)
return nil
}
displayProcesses(ps)
return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:25,代码来源:ps.go
示例18: cmdUpdate
func cmdUpdate(c *cli.Context) error {
client, err := updateClient()
if err != nil {
return stdcli.ExitError(err)
}
stdcli.Spinner.Prefix = "Updating convox/proxy: "
stdcli.Spinner.Start()
if err := updateProxy(); err != nil {
fmt.Printf("\x08\x08FAILED\n")
} else {
fmt.Printf("\x08\x08OK\n")
}
stdcli.Spinner.Stop()
stdcli.Spinner.Prefix = "Updating convox: "
stdcli.Spinner.Start()
opts := equinox.Options{
CurrentVersion: Version,
Channel: "stable",
HTTPClient: client,
}
if err := opts.SetPublicKeyPEM(publicKey); err != nil {
return stdcli.ExitError(err)
}
// check for update
r, err := equinox.Check("app_i8m2L26DxKL", opts)
switch {
case err == equinox.NotAvailableErr:
fmt.Println("\x08\x08Already up to date")
return nil
case err != nil:
return stdcli.ExitError(err)
}
// apply update
err = r.Apply()
if err != nil {
return stdcli.ExitError(err)
}
fmt.Printf("\x08\x08OK, %s\n", r.ReleaseVersion)
stdcli.Spinner.Stop()
return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:50,代码来源:update.go
示例19: cmdProxy
func cmdProxy(c *cli.Context) error {
if len(c.Args()) == 0 {
stdcli.Usage(c, "proxy")
return nil
}
for _, arg := range c.Args() {
parts := strings.SplitN(arg, ":", 3)
var host string
var port, hostport int
switch len(parts) {
case 2:
host = parts[0]
p, err := strconv.Atoi(parts[1])
if err != nil {
return stdcli.ExitError(err)
}
port = p
hostport = p
case 3:
host = parts[1]
p, err := strconv.Atoi(parts[0])
if err != nil {
return stdcli.ExitError(err)
}
port = p
p, err = strconv.Atoi(parts[2])
if err != nil {
return stdcli.ExitError(err)
}
hostport = p
default:
return stdcli.ExitError(fmt.Errorf("invalid argument: %s", arg))
}
go proxy("127.0.0.1", port, host, hostport, rackClient(c))
}
// block forever
select {}
}
开发者ID:gmelika,项目名称:rack,代码行数:50,代码来源:proxy.go
示例20: cmdServiceInfo
func cmdServiceInfo(c *cli.Context) error {
if len(c.Args()) != 1 {
stdcli.Usage(c, "info")
return nil
}
name := c.Args()[0]
service, err := rackClient(c).GetService(name)
if err != nil {
return stdcli.ExitError(err)
}
fmt.Printf("Name %s\n", service.Name)
fmt.Printf("Status %s\n", service.Status)
if service.Status == "failed" {
fmt.Printf("Reason %s\n", service.StatusReason)
}
if len(service.Exports) > 0 {
fmt.Printf("Exports\n")
for key, value := range service.Exports {
fmt.Printf(" %s: %s\n", key, value)
}
} else if service.URL != "" {
// NOTE: this branch is deprecated
fmt.Printf("URL %s\n", service.URL)
}
return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:33,代码来源:services.go
注:本文中的github.com/convox/rack/cmd/convox/stdcli.ExitError函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论