Skip to content

Commit c3ddd3e

Browse files
committed
feat: rebuild webhooktimer with lightweight scheduler, JSON persistence, and minimal UI
1 parent c50d0d0 commit c3ddd3e

18 files changed

Lines changed: 1802 additions & 1163 deletions

File tree

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.git
2+
.gitignore
3+
.github
4+
/data
5+
/bin
6+
/vendor
7+
*.db
8+
*.log

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ webhooktimer
66
*.exe
77
*.test
88
.DS_Store
9+
/data/
10+
*.corrupt-*

Dockerfile

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,25 @@
1-
# Build stage
2-
FROM golang:alpine AS builder
1+
FROM golang:1.22-alpine AS builder
32

4-
WORKDIR /app
3+
WORKDIR /src
54

6-
# Install build dependencies
7-
RUN apk add --no-cache git
5+
RUN apk add --no-cache ca-certificates
86

9-
# Copy go mod and sum files
10-
COPY go.mod go.sum ./
11-
12-
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
7+
COPY go.mod ./
138
RUN go mod download
149

15-
# Copy the source from the current directory to the Working Directory inside the container
1610
COPY . .
11+
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/webhooktimer .
1712

18-
# Build the Go app
19-
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o webhooktimer .
20-
21-
# Final stage
22-
FROM alpine:latest
23-
24-
RUN apk --no-cache add ca-certificates tzdata
25-
26-
WORKDIR /app
13+
FROM scratch
2714

28-
# Copy the Pre-built binary file from the previous stage
29-
COPY --from=builder /app/webhooktimer .
30-
COPY --from=builder /app/web ./web
15+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
16+
COPY --from=builder /out/webhooktimer /webhooktimer
3117

32-
# Expose port 8080 to the outside world
3318
EXPOSE 8080
19+
VOLUME ["/data"]
3420

35-
# Environment variables
3621
ENV PORT=8080
37-
ENV DB_PATH=/data/timers.db
22+
ENV STATE_PATH=/data/state.json
23+
ENV TZ=UTC
3824

39-
# Command to run the executable
40-
CMD ["./webhooktimer"]
25+
ENTRYPOINT ["/webhooktimer"]

README.md

Lines changed: 52 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,56 @@
11
# Webhook Timer
22

3-
A minimalistic timer for webhooks, designed specifically for N8N Webhooks.
4-
5-
## Features
6-
- Minimalistic Go-based daemon
7-
- SQLite persistence for configuration
8-
- Web-UI for managing timers
9-
- Support for Fixed and Random intervals
10-
- WebSocket for live countdown updates
11-
- Ultra-lightweight Docker Image (~26MB)
12-
13-
## ⚠️ AI GENERATED PROJECT ⚠️
14-
15-
> [!WARNING]
16-
> This project was **100% generated by AI** and is **not actively maintained**. Use it at your own risk.
17-
18-
## Deployment
19-
20-
### Docker Compose
21-
```yaml
22-
services:
23-
timerhook:
24-
image: ghcr.io/xhyperdevx/webhooktimer:latest
25-
ports:
26-
- "8080:8080"
27-
volumes:
28-
- ./data:/data
29-
restart: unless-stopped
3+
A tiny 24/7 webhook scheduler with a minimal web UI.
4+
5+
## What this rebuild includes
6+
7+
- Extremely simple UI (single page, no frontend dependencies)
8+
- Fixed or random intervals
9+
- Sleep window (no executions during configured quiet time)
10+
- Per-entry enable/disable
11+
- Live countdown to next execution
12+
- Last execution status and timestamp
13+
- Per-entry execution log (last 10)
14+
- **Run now** button with immediate success/error feedback
15+
- Atomic JSON state persistence (new format, old DB files are intentionally not reused)
16+
17+
## Why it is lightweight
18+
19+
- Pure Go + standard library only
20+
- No JS framework, no CSS framework, no websocket dependency
21+
- Static binary in a `scratch` container image
22+
23+
## Run locally
24+
25+
```bash
26+
go run .
3027
```
3128

32-
## Local Development
33-
1. Install Go 1.23+
34-
2. `go run main.go`
35-
3. Access UI at `http://localhost:8080`
29+
Open: `http://localhost:8080`
30+
31+
## Docker
32+
33+
```bash
34+
docker compose up --build
35+
```
36+
37+
### Environment variables
38+
39+
- `PORT` (default `8080`)
40+
- `STATE_PATH` (default `/data/state.json`)
41+
- `TZ` (default `UTC`, used for sleep window calculations)
42+
43+
## API (used by the UI)
44+
45+
- `GET /api/entries`
46+
- `POST /api/entries`
47+
- `PUT /api/entries/{id}`
48+
- `DELETE /api/entries/{id}`
49+
- `POST /api/entries/{id}/toggle`
50+
- `POST /api/entries/{id}/execute`
51+
- `GET /api/entries/{id}/logs`
52+
53+
## Notes
54+
55+
- The new persistence format is JSON, not SQLite.
56+
- If an old database exists from previous versions, it is ignored by design.

docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ services:
33
build: .
44
ports:
55
- "8080:8080"
6+
environment:
7+
- TZ=UTC
8+
- STATE_PATH=/data/state.json
69
volumes:
710
- ./data:/data
811
restart: unless-stopped

go.mod

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
11
module webhooktimer
22

3-
go 1.25.0
4-
5-
require (
6-
github.com/go-chi/chi/v5 v5.2.5
7-
github.com/google/uuid v1.6.0
8-
github.com/gorilla/websocket v1.5.3
9-
modernc.org/sqlite v1.30.0
10-
)
11-
12-
require (
13-
github.com/dustin/go-humanize v1.0.1 // indirect
14-
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
15-
github.com/mattn/go-isatty v0.0.20 // indirect
16-
github.com/ncruces/go-strftime v1.0.0 // indirect
17-
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
18-
golang.org/x/sys v0.42.0 // indirect
19-
modernc.org/gc/v3 v3.1.2 // indirect
20-
modernc.org/libc v1.70.0 // indirect
21-
modernc.org/mathutil v1.7.1 // indirect
22-
modernc.org/memory v1.11.0 // indirect
23-
modernc.org/strutil v1.2.1 // indirect
24-
modernc.org/token v1.1.0 // indirect
25-
)
3+
go 1.22

go.sum

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)