diff --git a/probs/.gitignore b/probes/.gitignore similarity index 99% rename from probs/.gitignore rename to probes/.gitignore index 6674a19e..50495748 100644 --- a/probs/.gitignore +++ b/probes/.gitignore @@ -62,4 +62,4 @@ dev.env prod.env test.env .venv -probs_dev +probes_dev diff --git a/probs/README.md b/probes/README.md similarity index 74% rename from probs/README.md rename to probes/README.md index 8f243f09..e69ba2e9 100644 --- a/probs/README.md +++ b/probes/README.md @@ -1,17 +1,17 @@ -# probs +# probes Running multiple operations simultaneously under one application. Execute one command: ```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: ```bash -probs service --config "~/.probs/config.json" +probes service --config "~/.probes/config.json" ``` Config example: diff --git a/probs/cmd/probs/cli.go b/probes/cmd/probes/cli.go similarity index 96% rename from probs/cmd/probs/cli.go rename to probes/cmd/probes/cli.go index 7c46c156..0b73b005 100644 --- a/probs/cmd/probs/cli.go +++ b/probes/cmd/probes/cli.go @@ -6,8 +6,8 @@ import ( "github.com/spf13/cobra" - probs "github.com/moonstream-to/api/probs/pkg" - engine "github.com/moonstream-to/api/probs/pkg/engine" + probes "github.com/moonstream-to/api/probes/pkg" + engine "github.com/moonstream-to/api/probes/pkg/engine" ) func CreateRootCommand() *cobra.Command { @@ -94,7 +94,7 @@ func CreateVersionCommand() *cobra.Command { Short: "Print the version number of workers", Long: `All software has versions. This is workers's.`, Run: func(cmd *cobra.Command, args []string) { - cmd.Println(probs.VERSION) + cmd.Println(probes.VERSION) }, } return versionCmd diff --git a/probs/cmd/probs/configs.go b/probes/cmd/probes/configs.go similarity index 91% rename from probs/cmd/probs/configs.go rename to probes/cmd/probes/configs.go index dc398861..649a74d4 100644 --- a/probs/cmd/probs/configs.go +++ b/probes/cmd/probes/configs.go @@ -9,20 +9,20 @@ import ( "path/filepath" "strings" - probs "github.com/moonstream-to/api/probs/pkg" - engine "github.com/moonstream-to/api/probs/pkg/engine" + probes "github.com/moonstream-to/api/probes/pkg" + engine "github.com/moonstream-to/api/probes/pkg/engine" ) var ( - DEFAULT_CONFIG_DIR_NAME = ".probs" + DEFAULT_CONFIG_DIR_NAME = ".probes" DEFAULT_CONFIG_FILE_NAME = "config.json" ) // Workers configuration type ServiceWorkersConfig struct { - Name string `json:"name"` - DbUri string `json:"db_uri"` - Workers []probs.ServiceWorker `json:"workers"` + Name string `json:"name"` + DbUri string `json:"db_uri"` + Workers []probes.ServiceWorker `json:"workers"` } 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) } - var serviceWorkers []probs.ServiceWorker + var serviceWorkers []probes.ServiceWorker // Link worker function for w, worker := range service.Workers { @@ -53,7 +53,7 @@ func ReadConfig(configPath string) (*[]ServiceWorkersConfig, int, error) { case "engine": for _, engineWorker := range engine.ENGINE_SUPPORTED_WORKERS { if worker.Name == engineWorker.Name { - serviceWorkers = append(serviceWorkers, probs.ServiceWorker{ + serviceWorkers = append(serviceWorkers, probes.ServiceWorker{ Name: worker.Name, Interval: worker.Interval, ExecFunction: engineWorker.ExecFunction, diff --git a/probs/cmd/probs/db.go b/probes/cmd/probes/db.go similarity index 100% rename from probs/cmd/probs/db.go rename to probes/cmd/probes/db.go diff --git a/probs/cmd/probs/main.go b/probes/cmd/probes/main.go similarity index 100% rename from probs/cmd/probs/main.go rename to probes/cmd/probes/main.go diff --git a/probs/cmd/probs/service.go b/probes/cmd/probes/service.go similarity index 90% rename from probs/cmd/probs/service.go rename to probes/cmd/probes/service.go index 2359a58a..bd19a874 100644 --- a/probs/cmd/probs/service.go +++ b/probes/cmd/probes/service.go @@ -7,7 +7,7 @@ import ( "sync" "time" - probs "github.com/moonstream-to/api/probs/pkg" + probes "github.com/moonstream-to/api/probes/pkg" ) func RunService(configPath string) error { @@ -44,7 +44,7 @@ func RunService(configPath string) error { 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() ctx := context.Background() diff --git a/probs/deploy/deploy.bash b/probes/deploy/deploy.bash similarity index 86% rename from probs/deploy/deploy.bash rename to probes/deploy/deploy.bash index 6646c23e..bb7889ee 100755 --- a/probs/deploy/deploy.bash +++ b/probes/deploy/deploy.bash @@ -21,7 +21,7 @@ SECRETS_DIR="${SECRETS_DIR:-/home/ubuntu/engineapi-secrets}" PARAMETERS_ENV_PATH="${SECRETS_DIR}/app.env" # API server service file -PROBS_SERVICE_FILE="probs.service" +PROBES_SERVICE_FILE="probes.service" set -eu @@ -61,8 +61,8 @@ XDG_RUNTIME_DIR="/run/user/1000" systemctl --user restart --no-block "${ENGINE_S echo echo -echo -e "${PREFIX_INFO} Replacing existing probs service and timer with: ${PROBS_SERVICE_FILE}" -chmod 644 "${SCRIPT_DIR}/${PROBS_SERVICE_FILE}" -cp "${SCRIPT_DIR}/${PROBS_SERVICE_FILE}" "/home/ubuntu/.config/systemd/user/${PROBS_SERVICE_FILE}" +echo -e "${PREFIX_INFO} Replacing existing probes service and timer with: ${PROBES_SERVICE_FILE}" +chmod 644 "${SCRIPT_DIR}/${PROBES_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 restart "${PROBS_SERVICE_FILE}" +XDG_RUNTIME_DIR="/run/user/1000" systemctl --user restart "${PROBES_SERVICE_FILE}" diff --git a/probs/deploy/probs.service b/probes/deploy/probes.service similarity index 63% rename from probs/deploy/probs.service rename to probes/deploy/probes.service index 5d5bef7b..b60ab7e6 100644 --- a/probs/deploy/probs.service +++ b/probes/deploy/probes.service @@ -5,12 +5,12 @@ StartLimitIntervalSec=300 StartLimitBurst=3 [Service] -WorkingDirectory=/home/ubuntu/api/probs +WorkingDirectory=/home/ubuntu/api/probes EnvironmentFile=/home/ubuntu/engineapi-secrets/app.env -ExecStart=/home/ubuntu/api/probs/probs service +ExecStart=/home/ubuntu/api/probes/probes service Restart=on-failure RestartSec=15s -SyslogIdentifier=probs +SyslogIdentifier=probes [Install] WantedBy=multi-user.target \ No newline at end of file diff --git a/probs/dev.sh b/probes/dev.sh similarity index 60% rename from probs/dev.sh rename to probes/dev.sh index b037f842..703f01ba 100755 --- a/probs/dev.sh +++ b/probes/dev.sh @@ -3,8 +3,8 @@ # Compile application and run with provided arguments 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" "$@" diff --git a/probs/go.mod b/probes/go.mod similarity index 91% rename from probs/go.mod rename to probes/go.mod index 39a4b5cf..b09b0814 100644 --- a/probs/go.mod +++ b/probes/go.mod @@ -1,4 +1,4 @@ -module github.com/moonstream-to/api/probs +module github.com/moonstream-to/api/probes go 1.19 diff --git a/probs/go.sum b/probes/go.sum similarity index 100% rename from probs/go.sum rename to probes/go.sum diff --git a/probs/pkg/data.go b/probes/pkg/data.go similarity index 94% rename from probs/pkg/data.go rename to probes/pkg/data.go index ef5299e9..4ef868db 100644 --- a/probs/pkg/data.go +++ b/probes/pkg/data.go @@ -1,4 +1,4 @@ -package probs +package probes import ( "context" diff --git a/probs/pkg/engine/engine.go b/probes/pkg/engine/engine.go similarity index 92% rename from probs/pkg/engine/engine.go rename to probes/pkg/engine/engine.go index 74eacffc..ee65963b 100644 --- a/probs/pkg/engine/engine.go +++ b/probes/pkg/engine/engine.go @@ -8,10 +8,10 @@ import ( "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", Description: "Clean all inactive call requests from database", LonDescription: "Remove records in call_requests database table with ttl value greater then now.", diff --git a/probs/pkg/version.go b/probes/pkg/version.go similarity index 68% rename from probs/pkg/version.go rename to probes/pkg/version.go index 72b56f78..dc932e4e 100644 --- a/probs/pkg/version.go +++ b/probes/pkg/version.go @@ -1,3 +1,3 @@ -package probs +package probes const VERSION string = "0.0.1" diff --git a/probs/sample.env b/probes/sample.env similarity index 100% rename from probs/sample.env rename to probes/sample.env