Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/lib/alimonitor-services/AbstractServiceSynchronizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const PassCorrectnessMonitor = require('./PassCorrectnessMonitor.js');

const defaultServiceSynchronizerOptions = {
forceStop: false,
rawCacheUse: true,
useCacheJsonInsteadIfPresent: false,
omitWhenCached: false,
rawCacheUse: process.env['RCT_DEV_USE_CACHE'] === 'false' ? false : true,
useCacheJsonInsteadIfPresent: process.env['RCT_DEV_USE_CACHE_INSTEAD'] === 'true' ? true : false,
omitWhenCached: process.env['RCT_DEV_OMIT_WHEN_CACHED'] === 'true' ? true : false,
batchSize: 4,
};

Expand Down Expand Up @@ -187,7 +187,7 @@ class AbstractServiceSynchronizer {
async getRawResponse(endpoint) {
if (this.useCacheJsonInsteadIfPresent && Cacher.isCached(this.name, endpoint)) {
// eslint-disable-next-line capitalized-comments
// this.logger.info(`using cached json :: ${Cacher.cachedFilePath(this.name, endpoint)}`);
this.logger.info(`using cached json :: ${Cacher.cachedFilePath(this.name, endpoint)}`);
return Cacher.getJsonSync(this.name, endpoint);
}
const onSucces = (endpoint, data) => {
Expand Down
10 changes: 8 additions & 2 deletions docker/dev.env
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ RCT_OPENID_WELL_KNOWN=${RCT_OPENID_WELL_KNOWN:-}

## database configuration
### common vars
RCT_DB_HOST=${DB_CONTATINER_NAME:-${RCT_DB_HOST:-o2rct_database-dev}}
RCT_DB_HOST=${RCT_DB_HOST:-${DB_CONTAINER_NAME:-o2rct_database-dev}}
RCT_DB_UNIXSS=${RCT_DB_UNIXSS:-/var/run/postgresql}
RCT_DB_NAME=${RCT_DB_NAME:-rct-db}
RCT_DB_PORT=5432
RCT_DB_PORT=${RCT_DB_PORT:-5432}
RCT_DB_USERNAME=${RCT_DB_USERNAME:-rct-user}
RCT_DB_PASSWORD=${RCT_DB_PASSWORD:-rct-passwd}

Expand All @@ -87,8 +87,14 @@ POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
POSTGRES_USER=${POSTGRES_USER:-postgres}
POSTGRES_DB=${POSTGRES_DB:-postgres}
PGDATA=${PGDATA:-/var/lib/postgresql/data/pgdata}
PGPORT=$RCT_DB_PORT
POSTGRES_HOST_AUTH_METHOD=scram-sha-256

MOCK_DB=${MOCK_DB:-false}
OTHER_SQL_MODIFY_DAEMON=${OTHER_SQL_MODIFY_DAEMON:-true}
MAIN_SQL_MODIFY_DAEMON=${MAIN_SQL_MODIFY_DAEMON:-true}

### cache
RCT_DEV_USE_CACHE=${RCT_DEV_USE_CACHE:-true}
RCT_DEV_USE_CACHE_INSTEAD=${RCT_DEV_USE_CACHE_INSTEAD:-true}
RCT_DEV_OMIT_WHEN_CACHED=${RCT_DEV_OMIT_WHEN_CACHED:-false}
10 changes: 0 additions & 10 deletions docker/docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,3 @@ services:
target: /postgres/run/database/cache
bind:
create_host_path: true


networks:
network:
driver: bridge
ipam:
driver: default
config:
- subnet: "172.200.201.0/24"
gateway: "172.200.201.1"
8 changes: 8 additions & 0 deletions docker/docker-compose-network.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
networks:
network:
driver: bridge
ipam:
driver: default
config:
- subnet: "172.200.20$SUBTARGET.0/24"
gateway: "172.200.20$SUBTARGET.1"
9 changes: 0 additions & 9 deletions docker/docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,3 @@ services:

database:
restart: "no"

networks:
network:
driver: bridge
ipam:
driver: default
config:
- subnet: "172.200.202.0/24"
gateway: "172.200.202.1"
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
application:
container_name: $APP_CONTAINER_NAME
working_dir: /opt/RunConditionTable
command: ["./scripts/check-host-and-exec.sh", "$DB_CONTAINER_NAME", "5432", "10", "--", "npm", "run", "start:$TARGET"]
command: ["./scripts/check-host-and-exec.sh", "$DB_CONTAINER_NAME", "$RCT_DB_PORT", "10", "--", "npm", "run", "start:$TARGET${START_TARGET_MODIFIER:+:$START_TARGET_MODIFIER}"]
stdin_open: true
tty: true
build:
Expand Down
3 changes: 2 additions & 1 deletion docker/test.env
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RCT_SYNC_TASK_AT_START=false

## database configuration
### general
RCT_DB_HOST=${DB_CONTATINER_NAME:-o2rct_database-test}
RCT_DB_HOST=${DB_CONTAINER_NAME:-o2rct_database-test0}
RCT_DB_NAME=rct-db
RCT_DB_PORT=5432
RCT_DB_USERNAME=rct-user
Expand All @@ -33,6 +33,7 @@ POSTGRES_PASSWORD=postgres
POSTGRES_USER=postgres
POSTGRES_DB=postgres
PGDATA=/var/lib/postgresql/data/pgdata
PGPORT=$RCT_DB_PORT
POSTGRES_HOST_AUTH_METHOD=md5

### endpoints
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
"reports:show": "open ./reports/**/*.html",
"reports:clean": "rm -rf ./reports; rm -rf .nyc_output",
"start:dev": "nodemon app/main.js --watch main.js --watch app --ignore app/public",
"start:dev:ND": "node app/main.js",
"start:dev:local": "(export RCT_DB_HOST=${RCT_DB_HOST:-localhost}; bash -c 'set -o allexport && ls && source ./docker/dev.env && set +o allexport && npm run start:dev')",
"deploy:db:local": "./database/setup-db.sh --env ./docker/dev.env",
"dev": "./rctmake prune,db:export,run,app:attach,stop --target dev",
"cdev": "export RCT_DEV_USE_CACHE=true; ./rctmake prune,db:export,run,app:attach,stop",
"idev": "node -e \"app = require('./app/application.js'); const { databaseManager: dbm } = app\" -i",
"node-dev-env": "(export RCT_DB_HOST=$(docker inspect o2rct_database-dev -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'); bash -c 'set -o allexport && ls && source ./docker/dev.env && set +o allexport && node')",
"dev:up": "./rctmake run[up],app:attach",
Expand Down
57 changes: 43 additions & 14 deletions rctmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@ Tasks are called stages.
Usage:
./$SCRIPT_NAME <STAGES> [<FLAGS>]
where STAGES is comma separeted list of stages performed sequentialy.
In default behaviour failure of one stage causes stopping pipeline execution, it can be changes via flag --ignore-errors.
Using moste of stages requires TARGET to be specified (default dev). It can be specified via flag -t|--target as test as well as via exporting env var TARGET;
By default, failure of any stage causes the stop of pipeline execution, it can be changed via flag --ignore-errors.
It is possible to specify TARGET (default dev). It can be specified via flag -t|--target as test as well as via exporting env var TARGET;
It is possible to specify SUBTARGET from range 1-9 (defualt 1 for TARGET dev). It can be specified via flag -s|--subtarget as test as well as via exporting env var SUBTARGET;
It can be used for running muliple instances of application simultaneously.
For TARGET test, 0 is the only allowed value for SUBTARGET and can be omitted.

Each stage is performed within the context of target.
Using conatiners build as dev and test is separted and can be performed in parallel.
Using containers built as dev and test is separted and can be performed in parallel.

Is seems that there is one case of target test, just something like ./rctmake run --target test.

Expand Down Expand Up @@ -83,8 +87,13 @@ Usage:
20. dump:(export|ex) -A|--archive-name <FILE> - export cached dump to tar.gz archive specified by the flag
21. dump:(import|im) -A|--archive-name <FILE> - import dumps from tar.gz archvie specified by the flag ito cache

! An additional -S|--service <SERVICE> flag can be specified for run, follow, stop and prune stages.
<SERVICE> $APP_CONTAINERS_OPT or $DB_CONTAINERS_OPT is the name of the service the stages are performed for.
Other options:
-S|--service <SERVICE> - flag can be specified for run, follow, stop and prune stages.
<SERVICE> $APP_CONTAINERS_OPT or $DB_CONTAINERS_OPT is the name of the service the stages are performed for.
-p|--rct-http-port PORT - flag for setting env var RCT_HTTP_PORT
-m|--target-modifier START_TARGET_MODIFIER - add modififying sufix to npm task like start:dev:START_TARGET_MODIFIER or start:test:START_TARGET_MODIFIER, depends on choosen TARGET
In case of dev mode modifier ND cause running node instead of nodemon.


$ERROR_MESSAGE_PRINT
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down Expand Up @@ -112,7 +121,6 @@ exit_codes_filter() {
return $LAST_CMD_EXIT_CODE
}


PREVIOD_USER_LOC=$(pwd);
DOCKER_DIR="$PROJECT_DIR/docker";
MAIN_DOCKER_COMPOSE_YML="$DOCKER_DIR/docker-compose.yml"
Expand All @@ -133,14 +141,22 @@ else
export TARGET=$2;
shift 2;
;;
-s|--subtarget)
export SUBTARGET=$2;
shift 2;
;;
-m|--target-modifier)
export START_TARGET_MODIFIER=$2;
shift 2;
;;
-p|--rct-http-port)
export RCT_HTTP_PORT=$2;
shift 2;
;;
-S|--service)
SERVICES="$SERVICES $(echo $2 | tr ',' ' ')";
shift 2;
;;
-m|--mock)
MOCK_DB=true;
shift 1;
;;
-F|--dump-file)
DUMP_FILE=$2;
shift 2;
Expand Down Expand Up @@ -169,12 +185,25 @@ else
fi

export TARGET=${TARGET:-dev}
export APP_CONTAINER_NAME="o2rct_application-$TARGET"
export DB_CONTAINER_NAME="o2rct_database-$TARGET"
if [[ "$TARGET" = "$DEV_MODE" ]]; then
SUBTARGET=${SUBTARGET:-1};
if ! [[ $SUBTARGET =~ ^[1-9]$ ]]; then
usage "incorrect SUBTARGET $SUBTARGET for target $TARGET";
fi;
elif [[ "$TARGET" = "$TEST_MODE" ]]; then
SUBTARGET=0;
else
usage "incorrect target $TARGET";
fi;

export SUBTARGET;
export APP_CONTAINER_NAME="o2rct_application-$TARGET$SUBTARGET";
export DB_CONTAINER_NAME="o2rct_database-$TARGET$SUBTARGET";

DOCKER_COMP_CMD_NO_ENV="docker compose -p $TARGET-o2rct
DOCKER_COMP_CMD_NO_ENV="docker compose -p $TARGET$SUBTARGET-o2rct
-f $MAIN_DOCKER_COMPOSE_YML
-f $DOCKER_DIR/docker-compose-$TARGET.yml
-f $DOCKER_DIR/docker-compose-network.yml
-f $DOCKER_DIR/docker-compose-volumes.yml
--env-file "$DOCKER_DIR/$TARGET.env"
--project-directory $PROJECT_DIR";
Expand Down Expand Up @@ -213,7 +242,7 @@ for stage in $STAGES; do
echo " *** do $stage";
case $stage in
prune)
$DOCKER_COMP_CMD_NO_ENV rm --stop --force -v $SERVICES;
$DOCKER_COMP_CMD_NO_ENV rm --stop --force -v $SERVICES && (docker network rm $TARGET$SUBTARGET-o2rct_network || exit_codes_filter 1);
;;

run*)
Expand Down