-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show push example under the detail page (#3739)
- Loading branch information
Showing
18 changed files
with
249 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/bin/bash | ||
# Filename: index.sh | ||
PUSH_URL="https://example.com/api/push/key?status=up&msg=OK&ping=" | ||
INTERVAL=60 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
docker run -d --restart=always --name uptime-kuma-push louislam/uptime-kuma:push "https://example.com/api/push/key?status=up&msg=OK&ping=" 60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,3 @@ | |
echo "Pushed!\n"; | ||
sleep(interval); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# Filename: index.ps1 | ||
$pushURL = "https://example.com/api/push/key?status=up&msg=OK&ping=" | ||
$interval = 60 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,3 @@ | |
urllib.request.urlopen(push_url) | ||
print("Pushed!\n") | ||
time.sleep(interval) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM node AS build | ||
RUN useradd --create-home kuma | ||
USER kuma | ||
WORKDIR /home/kuma | ||
ARG TARGETPLATFORM | ||
COPY --chown=kuma:kuma ./build/ ./build/ | ||
COPY --chown=kuma:kuma build.js build.js | ||
RUN node build.js $TARGETPLATFORM | ||
|
||
FROM debian:bookworm-slim AS release | ||
RUN useradd --create-home kuma | ||
USER kuma | ||
WORKDIR /home/kuma | ||
COPY --from=build /home/kuma/uptime-kuma-push ./uptime-kuma-push | ||
|
||
ENTRYPOINT ["/home/kuma/uptime-kuma-push"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const fs = require("fs"); | ||
const platform = process.argv[2]; | ||
|
||
if (!platform) { | ||
console.error("No platform??"); | ||
process.exit(1); | ||
} | ||
|
||
const supportedPlatforms = [ | ||
{ | ||
name: "linux/amd64", | ||
bin: "./build/uptime-kuma-push-amd64" | ||
}, | ||
{ | ||
name: "linux/arm64", | ||
bin: "./build/uptime-kuma-push-arm64" | ||
}, | ||
{ | ||
name: "linux/arm/v7", | ||
bin: "./build/uptime-kuma-push-armv7" | ||
} | ||
]; | ||
|
||
let platformObj = null; | ||
|
||
// Check if the platform is supported | ||
for (let i = 0; i < supportedPlatforms.length; i++) { | ||
if (supportedPlatforms[i].name === platform) { | ||
platformObj = supportedPlatforms[i]; | ||
break; | ||
} | ||
} | ||
|
||
if (platformObj) { | ||
let filename = platformObj.bin; | ||
|
||
if (!fs.existsSync(filename)) { | ||
console.error(`prebuilt: ${filename} is not found, please build it first`); | ||
process.exit(1); | ||
} | ||
|
||
fs.renameSync(filename, "./uptime-kuma-push"); | ||
process.exit(0); | ||
} else { | ||
console.error("Unsupported platform: " + platform); | ||
process.exit(1); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"scripts": { | ||
"build-docker": "npm run build-all && docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:push . --push --target release", | ||
"build-all": "npm run build-win && npm run build-linux-amd64 && npm run build-linux-arm64 && npm run build-linux-armv7 && npm run build-linux-armv6 && npm run build-linux-armv5 && npm run build-linux-riscv64", | ||
"build-win": "cross-env GOOS=windows GOARCH=amd64 go build -x -o ./build/uptime-kuma-push.exe uptime-kuma-push.go", | ||
"build-linux-amd64": "cross-env GOOS=linux GOARCH=amd64 go build -x -o ./build/uptime-kuma-push-amd64 uptime-kuma-push.go", | ||
"build-linux-arm64": "cross-env GOOS=linux GOARCH=arm64 go build -x -o ./build/uptime-kuma-push-arm64 uptime-kuma-push.go", | ||
"build-linux-armv7": "cross-env GOOS=linux GOARCH=arm GOARM=7 go build -x -o ./build/uptime-kuma-push-armv7 uptime-kuma-push.go", | ||
"build-linux-armv6": "cross-env GOOS=linux GOARCH=arm GOARM=6 go build -x -o ./build/uptime-kuma-push-armv6 uptime-kuma-push.go", | ||
"build-linux-armv5": "cross-env GOOS=linux GOARCH=arm GOARM=5 go build -x -o ./build/uptime-kuma-push-armv5 uptime-kuma-push.go", | ||
"build-linux-riscv64": "cross-env GOOS=linux GOARCH=riscv64 go build -x -o ./build/uptime-kuma-push-riscv64 uptime-kuma-push.go" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
os "os" | ||
"time" | ||
) | ||
|
||
func main() { | ||
if len(os.Args) < 2 { | ||
fmt.Fprintln(os.Stderr, "Usage: uptime-kuma-push <url> [<interval>]") | ||
os.Exit(1) | ||
} | ||
|
||
pushURL := os.Args[1] | ||
|
||
var interval time.Duration | ||
|
||
if len(os.Args) >= 3 { | ||
intervalString, err := time.ParseDuration(os.Args[2] + "s") | ||
interval = intervalString | ||
|
||
if err != nil { | ||
fmt.Fprintln(os.Stderr, "Error: Invalid interval", err) | ||
os.Exit(1) | ||
} | ||
|
||
} else { | ||
interval = 60 * time.Second | ||
} | ||
|
||
for { | ||
_, err := http.Get(pushURL) | ||
if err == nil { | ||
fmt.Print("Pushed!") | ||
} else { | ||
fmt.Print("Error: ", err) | ||
} | ||
|
||
fmt.Println(" Sleeping for", interval) | ||
time.Sleep(interval) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters