Compare commits

..
1 Commits
Author SHA1 Message Date
tikinang 254c10b484 seaweed testing, gitea actions 2026-09-04 08:52:35 +02:00
7 changed files with 91 additions and 0 deletions
Submodule
+1
Submodule gitea-actions added at 4c70a520d2
+3
View File
@@ -0,0 +1,3 @@
node_modules
package-lock.json
app
+3
View File
@@ -0,0 +1,3 @@
module github.com/tikinang/godummy
go 1.26.5
View File
+56
View File
@@ -0,0 +1,56 @@
package main
import (
"crypto/sha256"
"fmt"
"net/http"
"strconv"
"sync"
"time"
)
var BuildTime string
const ramChunkSize = 100 * 1024 * 1024 // 0.1 GiB
var (
ramMu sync.Mutex
ramChunks [][]byte
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
_, _ = fmt.Fprintln(w, BuildTime)
})
http.HandleFunc("/ram", func(w http.ResponseWriter, r *http.Request) {
chunk := make([]byte, ramChunkSize)
for i := range chunk {
chunk[i] = 1
}
ramMu.Lock()
ramChunks = append(ramChunks, chunk)
total := len(ramChunks)
ramMu.Unlock()
w.WriteHeader(http.StatusOK)
_, _ = fmt.Fprintf(w, "allocated 0.1 GiB, total held: %.1f GiB (%d chunks)\n", float64(total)*0.1, total)
})
http.HandleFunc("/cpu", func(w http.ResponseWriter, r *http.Request) {
iterations := 1_000_000
if n, err := strconv.Atoi(r.URL.Query().Get("n")); err == nil && n > 0 {
iterations = n
}
start := time.Now()
sum := sha256.Sum256([]byte("zerops"))
for i := 0; i < iterations; i++ {
sum = sha256.Sum256(sum[:])
}
elapsed := time.Since(start)
w.WriteHeader(http.StatusOK)
_, _ = fmt.Fprintf(w, "computed %x in %s (%d iterations)\n", sum, elapsed, iterations)
})
_ = http.ListenAndServe(":8080", nil)
}
@@ -0,0 +1,6 @@
services:
- hostname: app
type: ubuntu@24.04
maxContainers: 1
buildFromGit: https://github.com/tikinang/godummy
enableSubdomainAccess: true
+22
View File
@@ -0,0 +1,22 @@
zerops:
- setup: test
build:
base: ubuntu/go@latest
buildCommands:
- go build -ldflags "-X main.BuildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o app main.go
cache: true
deployFiles:
- app
run:
base: ubuntu@latest
ports:
- port: 8080
httpSupport: true
startCommands:
- name: webserver
command: /var/www/app
- name: mount
initCommands:
- sudo mkdir -p /mnt/vol
- sudo chown -R zerops:zerops /mnt/vol
command: sudo /opt/zerops/bin/weed-3-85 mount -filer node-stable-1.db.sharedstorage.zerops:8888 -dir /mnt/vol