Compare commits
1
Commits
6f63abecea
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
254c10b484 |
Submodule
+1
Submodule gitea-actions added at 4c70a520d2
@@ -0,0 +1,3 @@
|
|||||||
|
node_modules
|
||||||
|
package-lock.json
|
||||||
|
app
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
module github.com/tikinang/godummy
|
||||||
|
|
||||||
|
go 1.26.5
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
Reference in New Issue
Block a user