mirror of
https://github.com/aljazceru/cypherapps.git
synced 2025-12-17 05:14:22 +01:00
Batcher cypherapp
This commit is contained in:
18
batcher/data/config.json
Normal file
18
batcher/data/config.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"LOG": "DEBUG",
|
||||||
|
"BASE_DIR": "/batcher",
|
||||||
|
"DATA_DIR": "data",
|
||||||
|
"DB_NAME": "batcher.sqlite",
|
||||||
|
"URL_SERVER": "http://batcher",
|
||||||
|
"URL_PORT": 8000,
|
||||||
|
"URL_CTX_WEBHOOKS": "webhooks",
|
||||||
|
"SESSION_TIMEOUT": 600,
|
||||||
|
"CN_URL": "https://gatekeeper:2009/v0",
|
||||||
|
"CN_API_ID": "003",
|
||||||
|
"CN_API_KEY": "39b83c35972aeb81a242bfe189dc0a22da5ac6cbb64072b492f2d46519a97618",
|
||||||
|
"DEFAULT_BATCHER_ID": 1,
|
||||||
|
"BATCH_TIMEOUT_MINUTES": 60,
|
||||||
|
"CHECK_THRESHOLD_MINUTES": 10,
|
||||||
|
"BATCH_THRESHOLD_AMOUNT": 0.5,
|
||||||
|
"BATCH_CONF_TARGET": 6
|
||||||
|
}
|
||||||
25
batcher/docker-compose.yaml
Normal file
25
batcher/docker-compose.yaml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
version: "3"
|
||||||
|
|
||||||
|
services:
|
||||||
|
batcher:
|
||||||
|
environment:
|
||||||
|
- "TRACING=1"
|
||||||
|
- "CYPHERNODE_URL=https://gatekeeper:${GATEKEEPER_PORT}"
|
||||||
|
image: cyphernode/batcher:v0.1.0
|
||||||
|
entrypoint: ["npm", "run", "start:dev"]
|
||||||
|
volumes:
|
||||||
|
- "$APP_SCRIPT_PATH/data:/batcher/data"
|
||||||
|
- "$GATEKEEPER_DATAPATH/certs/cert.pem:/batcher/cert.pem:ro"
|
||||||
|
networks:
|
||||||
|
- cyphernodeappsnet
|
||||||
|
restart: always
|
||||||
|
labels:
|
||||||
|
- "traefik.docker.network=cyphernodeappsnet"
|
||||||
|
- "traefik.frontend.rule=PathPrefixStrip:/batcher"
|
||||||
|
- "traefik.frontend.passHostHeader=true"
|
||||||
|
- "traefik.enable=true"
|
||||||
|
- "traefik.port=8000"
|
||||||
|
- "traefik.frontend.auth.basic.users=<username:bcrypt>"
|
||||||
|
networks:
|
||||||
|
cyphernodeappsnet:
|
||||||
|
external: true
|
||||||
0
batcher/isCoreApp
Normal file
0
batcher/isCoreApp
Normal file
40
batcher/test.sh
Normal file
40
batcher/test.sh
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
timeout_feature() {
|
||||||
|
local interval=10
|
||||||
|
local totaltime=60
|
||||||
|
local testwhat=${1}
|
||||||
|
local returncode
|
||||||
|
local endtime=$(($(date +%s) + ${totaltime}))
|
||||||
|
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
eval ${testwhat}
|
||||||
|
returncode=$?
|
||||||
|
|
||||||
|
# If no error or 2 minutes passed, we get out of this loop
|
||||||
|
([ "${returncode}" -eq "0" ] || [ $(date +%s) -gt ${endtime} ]) && break
|
||||||
|
|
||||||
|
printf "\e[1;31mMaybe it's too early, I'll retry every ${interval} seconds for $((${totaltime} / 60)) minutes ($((${endtime} - $(date +%s))) seconds left).\e[1;0m\r\n"
|
||||||
|
|
||||||
|
sleep ${interval}
|
||||||
|
done
|
||||||
|
|
||||||
|
return ${returncode}
|
||||||
|
}
|
||||||
|
|
||||||
|
do_test() {
|
||||||
|
local rc
|
||||||
|
rc=$(curl -k -s -o /dev/null -w "%{http_code}" https://127.0.0.1:${TRAEFIK_HTTPS_PORT}/batcher)
|
||||||
|
[ "${rc}" -ne "401" ] && return 400
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
export TRAEFIK_HTTPS_PORT
|
||||||
|
|
||||||
|
timeout_feature do_test
|
||||||
|
returncode=$?
|
||||||
|
|
||||||
|
# return 0: tests cool
|
||||||
|
# return 1: tests failed
|
||||||
|
return $returncode
|
||||||
Reference in New Issue
Block a user