Fixed typo with probes

pull/813/head
kompotkot 2023-06-13 08:02:48 +00:00
rodzic f9646ea8ba
commit b2bb3b70a9
16 zmienionych plików z 32 dodań i 32 usunięć

Wyświetl plik

@ -62,4 +62,4 @@ dev.env
prod.env prod.env
test.env test.env
.venv .venv
probs_dev probes_dev

Wyświetl plik

@ -1,17 +1,17 @@
# probs # probes
Running multiple operations simultaneously under one application. Running multiple operations simultaneously under one application.
Execute one command: Execute one command:
```bash ```bash
probs engine clean-call-requests --db-uri "${ENGINE_DB_URI}" probes engine clean-call-requests --db-uri "${ENGINE_DB_URI}"
``` ```
Run service with configuration: Run service with configuration:
```bash ```bash
probs service --config "~/.probs/config.json" probes service --config "~/.probes/config.json"
``` ```
Config example: Config example:

Wyświetl plik

@ -6,8 +6,8 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
probs "github.com/moonstream-to/api/probs/pkg" probes "github.com/moonstream-to/api/probes/pkg"
engine "github.com/moonstream-to/api/probs/pkg/engine" engine "github.com/moonstream-to/api/probes/pkg/engine"
) )
func CreateRootCommand() *cobra.Command { func CreateRootCommand() *cobra.Command {
@ -94,7 +94,7 @@ func CreateVersionCommand() *cobra.Command {
Short: "Print the version number of workers", Short: "Print the version number of workers",
Long: `All software has versions. This is workers's.`, Long: `All software has versions. This is workers's.`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
cmd.Println(probs.VERSION) cmd.Println(probes.VERSION)
}, },
} }
return versionCmd return versionCmd

Wyświetl plik

@ -9,20 +9,20 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
probs "github.com/moonstream-to/api/probs/pkg" probes "github.com/moonstream-to/api/probes/pkg"
engine "github.com/moonstream-to/api/probs/pkg/engine" engine "github.com/moonstream-to/api/probes/pkg/engine"
) )
var ( var (
DEFAULT_CONFIG_DIR_NAME = ".probs" DEFAULT_CONFIG_DIR_NAME = ".probes"
DEFAULT_CONFIG_FILE_NAME = "config.json" DEFAULT_CONFIG_FILE_NAME = "config.json"
) )
// Workers configuration // Workers configuration
type ServiceWorkersConfig struct { type ServiceWorkersConfig struct {
Name string `json:"name"` Name string `json:"name"`
DbUri string `json:"db_uri"` DbUri string `json:"db_uri"`
Workers []probs.ServiceWorker `json:"workers"` Workers []probes.ServiceWorker `json:"workers"`
} }
func ReadConfig(configPath string) (*[]ServiceWorkersConfig, int, error) { func ReadConfig(configPath string) (*[]ServiceWorkersConfig, int, error) {
@ -45,7 +45,7 @@ func ReadConfig(configPath string) (*[]ServiceWorkersConfig, int, error) {
return nil, totalWorkersNum, fmt.Errorf("unable to load database URI for service %s", service.Name) return nil, totalWorkersNum, fmt.Errorf("unable to load database URI for service %s", service.Name)
} }
var serviceWorkers []probs.ServiceWorker var serviceWorkers []probes.ServiceWorker
// Link worker function // Link worker function
for w, worker := range service.Workers { for w, worker := range service.Workers {
@ -53,7 +53,7 @@ func ReadConfig(configPath string) (*[]ServiceWorkersConfig, int, error) {
case "engine": case "engine":
for _, engineWorker := range engine.ENGINE_SUPPORTED_WORKERS { for _, engineWorker := range engine.ENGINE_SUPPORTED_WORKERS {
if worker.Name == engineWorker.Name { if worker.Name == engineWorker.Name {
serviceWorkers = append(serviceWorkers, probs.ServiceWorker{ serviceWorkers = append(serviceWorkers, probes.ServiceWorker{
Name: worker.Name, Name: worker.Name,
Interval: worker.Interval, Interval: worker.Interval,
ExecFunction: engineWorker.ExecFunction, ExecFunction: engineWorker.ExecFunction,

Wyświetl plik

@ -7,7 +7,7 @@ import (
"sync" "sync"
"time" "time"
probs "github.com/moonstream-to/api/probs/pkg" probes "github.com/moonstream-to/api/probes/pkg"
) )
func RunService(configPath string) error { func RunService(configPath string) error {
@ -44,7 +44,7 @@ func RunService(configPath string) error {
return nil return nil
} }
func RunWorker(wg *sync.WaitGroup, worker probs.ServiceWorker, serviceName, dbUri string) error { func RunWorker(wg *sync.WaitGroup, worker probes.ServiceWorker, serviceName, dbUri string) error {
defer wg.Done() defer wg.Done()
ctx := context.Background() ctx := context.Background()

Wyświetl plik

@ -21,7 +21,7 @@ SECRETS_DIR="${SECRETS_DIR:-/home/ubuntu/engineapi-secrets}"
PARAMETERS_ENV_PATH="${SECRETS_DIR}/app.env" PARAMETERS_ENV_PATH="${SECRETS_DIR}/app.env"
# API server service file # API server service file
PROBS_SERVICE_FILE="probs.service" PROBES_SERVICE_FILE="probes.service"
set -eu set -eu
@ -61,8 +61,8 @@ XDG_RUNTIME_DIR="/run/user/1000" systemctl --user restart --no-block "${ENGINE_S
echo echo
echo echo
echo -e "${PREFIX_INFO} Replacing existing probs service and timer with: ${PROBS_SERVICE_FILE}" echo -e "${PREFIX_INFO} Replacing existing probes service and timer with: ${PROBES_SERVICE_FILE}"
chmod 644 "${SCRIPT_DIR}/${PROBS_SERVICE_FILE}" chmod 644 "${SCRIPT_DIR}/${PROBES_SERVICE_FILE}"
cp "${SCRIPT_DIR}/${PROBS_SERVICE_FILE}" "/home/ubuntu/.config/systemd/user/${PROBS_SERVICE_FILE}" cp "${SCRIPT_DIR}/${PROBES_SERVICE_FILE}" "/home/ubuntu/.config/systemd/user/${PROBES_SERVICE_FILE}"
XDG_RUNTIME_DIR="/run/user/1000" systemctl --user daemon-reload XDG_RUNTIME_DIR="/run/user/1000" systemctl --user daemon-reload
XDG_RUNTIME_DIR="/run/user/1000" systemctl --user restart "${PROBS_SERVICE_FILE}" XDG_RUNTIME_DIR="/run/user/1000" systemctl --user restart "${PROBES_SERVICE_FILE}"

Wyświetl plik

@ -5,12 +5,12 @@ StartLimitIntervalSec=300
StartLimitBurst=3 StartLimitBurst=3
[Service] [Service]
WorkingDirectory=/home/ubuntu/api/probs WorkingDirectory=/home/ubuntu/api/probes
EnvironmentFile=/home/ubuntu/engineapi-secrets/app.env EnvironmentFile=/home/ubuntu/engineapi-secrets/app.env
ExecStart=/home/ubuntu/api/probs/probs service ExecStart=/home/ubuntu/api/probes/probes service
Restart=on-failure Restart=on-failure
RestartSec=15s RestartSec=15s
SyslogIdentifier=probs SyslogIdentifier=probes
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

Wyświetl plik

@ -3,8 +3,8 @@
# Compile application and run with provided arguments # Compile application and run with provided arguments
set -e set -e
PROGRAM_NAME="probs_dev" PROGRAM_NAME="probes_dev"
go build -o "$PROGRAM_NAME" cmd/probs/*.go go build -o "$PROGRAM_NAME" cmd/probes/*.go
./"$PROGRAM_NAME" "$@" ./"$PROGRAM_NAME" "$@"

Wyświetl plik

@ -1,4 +1,4 @@
module github.com/moonstream-to/api/probs module github.com/moonstream-to/api/probes
go 1.19 go 1.19

Wyświetl plik

@ -1,4 +1,4 @@
package probs package probes
import ( import (
"context" "context"

Wyświetl plik

@ -8,10 +8,10 @@ import (
"github.com/jackc/pgx/v5/pgxpool" "github.com/jackc/pgx/v5/pgxpool"
probs "github.com/moonstream-to/api/probs/pkg" probes "github.com/moonstream-to/api/probes/pkg"
) )
var ENGINE_SUPPORTED_WORKERS = []probs.ServiceWorker{{ var ENGINE_SUPPORTED_WORKERS = []probes.ServiceWorker{{
Name: "clean-call-requests", Name: "clean-call-requests",
Description: "Clean all inactive call requests from database", Description: "Clean all inactive call requests from database",
LonDescription: "Remove records in call_requests database table with ttl value greater then now.", LonDescription: "Remove records in call_requests database table with ttl value greater then now.",

Wyświetl plik

@ -1,3 +1,3 @@
package probs package probes
const VERSION string = "0.0.1" const VERSION string = "0.0.1"