Skip to content

Commit

Permalink
Change port numbers (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenElgar authored Oct 22, 2021
1 parent 5d0dbc6 commit a900b57
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .dev/config.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
httpPort = 4001
httpPort = 44643
noDaemon = true

[client]
url = "http://localhost:4001"
url = "http://localhost:44643"

[gui]
port = 3001
Expand Down
4 changes: 2 additions & 2 deletions doc/local-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ cd path/to/exo
exo run
```

If all goes well, you should be able to manage your server and gui processes at [http://localhost:4000](http://localhost:4000). Please note that this is the _installed_ exo gui that you are viewing, not the development instance. The development instance runs on port `4001` and can be accessed at [http://localhost:4001](http://localhost:4001). The development mode GUI has a "DEV" indicator in the footer so that you can tell at a glance which instance you are using.
If all goes well, you should be able to manage your server and gui processes at [http://localhost:43643](http://localhost:43643). Please note that this is the _installed_ exo gui that you are viewing, not the development instance. The development instance runs on port `44643` and can be accessed at [http://localhost:44643](http://localhost:44643). The development mode GUI has a "DEV" indicator in the footer so that you can tell at a glance which instance you are using.

The `exo` CLI runs against the installed instance by default, but you can change to the development instance by adding the following to your exo config file (located at `~/.exo/config.toml`):

```
[client]
url = "http://localhost:4001"
url = "http://localhost:44643"
```

Now all `exo` commands will run against the development instance. To run against the installed instance again, remove or comment out these lines from your `config.toml`.
Expand Down
2 changes: 1 addition & 1 deletion gui/.env.development
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VITE_API_PORT=4001
VITE_API_PORT=44643
3 changes: 2 additions & 1 deletion gui/.env.production
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
VITE_API_PORT=4000
# FIXME: this should come from the config.toml
VITE_API_PORT=43643
4 changes: 2 additions & 2 deletions gui/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';

// Vite server runs on 3001 in development, which is proxied from the
// `exo` server running on 4001. In production, exo serves the GUI and
// the API on port 4000.
// `exo` server running on 44643. In production, exo serves the GUI and
// the API on port 43643.
const port = 3001;

// https://vitejs.dev/config/
Expand Down
4 changes: 2 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ func setDefaults(cfg *Config) {
}

if cfg.HTTPPort == 0 {
cfg.HTTPPort = 4000
cfg.HTTPPort = 43643
}

// Log
if cfg.Log.SyslogPort == 0 {
cfg.Log.SyslogPort = 4500
cfg.Log.SyslogPort = 43550
}

// GUI
Expand Down
2 changes: 1 addition & 1 deletion internal/config/defaultconfig.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# runDir = "/path/to/exo-home/run"

# Port the daemon service listens on.
# httpPort = 4000
# httpPort = 43643

## Logging subsystem that collects logs from running services.
[log]
Expand Down
15 changes: 15 additions & 0 deletions internal/exod/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,21 @@ func RunServer(ctx context.Context, flags map[string]string) {
Next: mux,
})

go func() {
// Add a redirect to the new port number if a request is received on the old
// one. Ignore any error as that's most likely some other service attempting
// to listen on the same port. This is to allow people to upgrade seamlessly
// but we should be able to remove it soon after the next release. (Written
// on the 19th of Oct 2021)
http.ListenAndServe(":4000", http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
uri := *req.URL
uri.Host = fmt.Sprintf("localhost:%d", cfg.HTTPPort)
redirectTo := uri.String()
http.Redirect(resp, req, redirectTo, http.StatusMovedPermanently)
return
}))
}()

addr := cmdutil.GetAddr(cfg)
logger.Infof("listening for API calls at %s", addr)
cmdutil.ListenAndServe(ctx, &http.Server{
Expand Down

0 comments on commit a900b57

Please sign in to comment.