Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ services:
image: ghcr.io/daltonbr/wol-server:latest
network_mode: "host" # Required for WOL broadcast on Linux
environment:
PORT: "5000" # Optional, defaults to 5000
WOL_CONFIG: |
devices:
desktop:
Expand Down Expand Up @@ -76,6 +77,13 @@ curl http://localhost:5000/status

## Configuration

### Environment Variables

| Variable | Description | Default |
| -------- | ----------- | ------- |
| PORT | HTTP server port | 5000 |
| WOL_CONFIG | YAML configuration (inline) | - |

### Option 1: Environment Variable (Docker)

Set `WOL_CONFIG` with YAML content (see docker-compose example above).
Expand Down
15 changes: 14 additions & 1 deletion docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ cp config.example.yaml ~/.config/wol-server/config.yaml
go run .
```

**Server runs on:** `http://localhost:5000`
**Server runs on:** `http://localhost:5000` (or set `PORT` environment variable)

**Change port:**

```bash
PORT=8080 go run .
```

## Testing

Expand Down Expand Up @@ -89,9 +95,16 @@ docker build -t wol-server:local .
**Run locally built image:**

```bash
# Default port (5000)
docker run --rm -p 5000:5000 \
-e WOL_CONFIG="$(cat ~/.config/wol-server/config.yaml)" \
wol-server:local

# Custom port
docker run --rm -p 8080:8080 \
-e PORT=8080 \
-e WOL_CONFIG="$(cat ~/.config/wol-server/config.yaml)" \
wol-server:local
```

## Publishing to GHCR
Expand Down
11 changes: 9 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log"
"net"
"net/http"
"os"
"strconv"
)

Expand All @@ -15,10 +16,16 @@ func main() {
log.Println("Server will only accept direct parameters (mac/ip/port)")
}

// Get port from environment or use default
port := os.Getenv("PORT")
if port == "" {
port = "5000"
}

Comment thread
daltonbr marked this conversation as resolved.
http.HandleFunc("/wake", handler)
http.HandleFunc("/status", statusHandler)
fmt.Println("Server is listening on port :5000")
log.Fatal(http.ListenAndServe(":5000", nil))
fmt.Printf("Server is listening on port :%s\n", port)
log.Fatal(http.ListenAndServe(":"+port, nil))
Comment thread
daltonbr marked this conversation as resolved.
Outdated
}

func handler(w http.ResponseWriter, r *http.Request) {
Expand Down