add script/server
This commit is contained in:
@@ -12,15 +12,19 @@ integration tests, and joint line coverage.
|
|||||||
## Running
|
## Running
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
clojure -X:run
|
script/server [port]
|
||||||
```
|
```
|
||||||
|
|
||||||
The server listens on port `3000` by default; set `PORT` to change it:
|
The server listens on port `3000` by default; pass a port argument or set `PORT` to change it
|
||||||
|
(the argument wins):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
PORT=8080 clojure -X:run
|
script/server 8080
|
||||||
|
PORT=8080 script/server
|
||||||
```
|
```
|
||||||
|
|
||||||
|
This is a thin wrapper around `clojure -X:run`, which also honors `PORT`.
|
||||||
|
|
||||||
Or build and run the container:
|
Or build and run the container:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
Executable
+13
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Start the server. Usage: script/server [port]
|
||||||
|
# The port defaults to $PORT, then 3000.
|
||||||
|
set -euo pipefail
|
||||||
|
cd "$(dirname "$0")/.."
|
||||||
|
|
||||||
|
port=${1:-${PORT:-3000}}
|
||||||
|
if [[ ! $port =~ ^[0-9]+$ ]] || (( port < 1 || port > 65535 )); then
|
||||||
|
echo "usage: script/server [port] (port must be 1-65535, got '$port')" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
PORT=$port exec clojure -X:run
|
||||||
Reference in New Issue
Block a user