kopia lustrzana https://github.com/bugout-dev/moonstream
Merge pull request #240 from bugout-dev/db-health-server
Simple ping moonstream database servicepull/242/head
commit
bf8a3ebb09
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Deployment script - intended to run on Moonstream database server
|
||||
|
||||
# Main
|
||||
SCRIPT_DIR="$(realpath $(dirname $0))"
|
||||
SERVICE_FILE="${SCRIPT_DIR}/moonstreamdb.service"
|
||||
|
||||
echo
|
||||
echo
|
||||
echo "Replacing existing moonstreamdb service definition with ${SERVICE_FILE}"
|
||||
chmod 644 "${SERVICE_FILE}"
|
||||
cp "${SERVICE_FILE}" /etc/systemd/system/moonstreamdb.service
|
||||
systemctl daemon-reload
|
||||
systemctl restart moonstreamdb.service
|
||||
systemctl status moonstreamdb.service
|
|
@ -0,0 +1,13 @@
|
|||
[Unit]
|
||||
Description=moonstreamdb-service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=ubuntu
|
||||
Group=www-data
|
||||
WorkingDirectory=/home/ubuntu/moonstream/db/server
|
||||
ExecStart=moonstreamdb
|
||||
SyslogIdentifier=moonstreamdb
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -0,0 +1,3 @@
|
|||
module moonstreamdb
|
||||
|
||||
go 1.17
|
|
@ -0,0 +1,26 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type PingResponse struct {
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
func ping(w http.ResponseWriter, req *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
response := PingResponse{Status: "ok"}
|
||||
json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
||||
func main() {
|
||||
address := "0.0.0.0:8931"
|
||||
fmt.Printf("Starting server at %s\n", address)
|
||||
|
||||
http.HandleFunc("/ping", ping)
|
||||
|
||||
http.ListenAndServe(address, nil)
|
||||
}
|
Ładowanie…
Reference in New Issue