Skip to content
Permalink
Browse files

add -c, --command flag to `up start`. Closes #564

  • Loading branch information...
tj committed Jan 31, 2018
1 parent 9b2dc45 commit 5b3b6c7e378e359b9723ef00dcd852014f677ac7
Showing with 21 additions and 3 deletions.
  1. +13 −2 docs/06-commands.md
  2. +8 −1 internal/cli/start/start.go
@@ -487,20 +487,23 @@ $ up metrics production -s 15d

Start development server. The development server runs the same proxy that is used in production for serving, so you can test a static site or application locally with the same feature-set.

Currently `up start` does not work with cross-compiled languages such as Go or Crystal.
See [Stage Overrides](https://up.docs.apex.sh/#configuration.stage_overrides) for an example of overriding the proxy command per-stage, especially useful in development.

```
Start development server.
Usage:
up start [<flags>]
Flags:
-h, --help Output usage information.
-r, --region=REGION Override the region.
-C, --chdir="." Change working directory.
-v, --verbose Enable verbose log output.
--format="text" Output formatter.
--version Show application version.
-c, --command=COMMAND Proxy command override
--address=":3000" Address for server.
```

@@ -518,6 +521,14 @@ Start development server on port 5000.
$ up start --address :5000
```

Override proxy command.

```
$ up start -c 'go run main.go'
$ up start -c 'node --some-flag app.js'
$ up start -c 'parcel'
```

## Domains

Manage domain names, and purchase them from AWS Route53 as the registrar.
@@ -18,6 +18,8 @@ func init() {
cmd := root.Command("start", "Start development server.")
cmd.Example(`up start`, "Start development server on port 3000.")
cmd.Example(`up start --address :5000`, "Start development server on port 5000.")
cmd.Example(`up start -c 'go run main.go'`, "Override proxy command.")
command := cmd.Flag("command", "Proxy command override").Short('c').String()

addr := cmd.Flag("address", "Address for server.").Default(":3000").String()

@@ -34,7 +36,8 @@ func init() {
}

stats.Track("Start", map[string]interface{}{
"address": *addr,
"address": *addr,
"has_command": *command != "",
})

if err := p.Init("development"); err != nil {
@@ -45,6 +48,10 @@ func init() {
return errors.Wrap(err, "overriding")
}

if s := *command; s != "" {
c.Proxy.Command = s
}

h, err := handler.FromConfig(c)
if err != nil {
return errors.Wrap(err, "selecting handler")

0 comments on commit 5b3b6c7

Please sign in to comment.
You can’t perform that action at this time.