Repository: hashicorp/nomad
File: command/job_start.go (Go)

Code before:

import (
	"fmt"
	"strings"
	"time"

	"github.com/hashicorp/nomad/api"
	"github.com/hashicorp/nomad/api/contexts"
	"github.com/posener/complete"
)

type JobStartCommand struct {
	Meta
}

func (c *JobStartCommand) Help() string {
	helpText := `
Usage: nomad job start [options] <job>
Alias: nomad start


 Starts a stopped job. The job must be currently registered with Nomad. Upon
 successful start, an interactive monitor session will start to display log
 lines as the job starts its allocations based on its most recent version.
 It is safe to exit the monitor early using ctrl+c.


 When ACLs are enabled, this command requires a token with the 'submit-job'
 and 'read-job' capabilities for the job's namespace. The 'list-jobs'
 capability is required to run the command with job prefixes instead of exact
 job IDs.


General Options:


 ` + generalOptionsUsage(usageOptsDefault) + `


Start Options:


 -detach
   Return immediately instead of entering monitor mode. After the
   job start command is submitted, a new evaluation ID is printed to the
   screen, which can be used to examine the evaluation using the eval-status
   command.

 -verbose
   Display full information.
`

Review comment (suggestion):
I want to make explicit what Nomad is doing here in terms of job versions, as that seems to be a source of confusion for users. I've lifted some of this text from `job run`:

```suggestion
Starts a stopped job. The job must be currently registered. Nomad will create a
new version of the job based on its most recent version. Upon successful start,
Nomad will enter an interactive monitor session. This is useful to watch
Nomad's internals make scheduling decisions and place the submitted work onto
nodes. The monitor will end once job placement is done. It is safe to exit the
monitor early using ctrl+c.
```

(We'll want this to be in the docs too.)

Code after:

import (
	"fmt"
	"strings"
	"time"

	"github.com/hashicorp/nomad/api/contexts"
	"github.com/posener/complete"
)

type JobStartCommand struct {
	Meta
}

func (c *JobStartCommand) Help() string {
	helpText := `
Usage: nomad job start [options] <job>
Alias: nomad start

 Starts a stopped job. The job must be currently registered. Nomad will create a
 new version of the job based on its most recent version. Upon successful start,
 Nomad will enter an interactive monitor session. This is useful to watch
 Nomad's internals make scheduling decisions and place the submitted work onto
 nodes. The monitor will end once job placement is done. It is safe to exit the
 monitor early using ctrl+c.

 When ACLs are enabled, this command requires a token with the 'submit-job'
 capability for the job's namespace.

General Options:

 ` + generalOptionsUsage(usageOptsDefault) + `

Start Options:

 -detach
   Return immediately instead of entering monitor mode. After the
   job start command is submitted, a new evaluation ID is printed to the
   screen, which can be used to examine the evaluation using the eval-status
   command.

 -verbose
   Display full information.
`
	return strings.TrimSpace(helpText)
}

func (c *JobStartCommand) Synopsis() string {
	return "Start a stopped job"
}