diff --git a/.infrastructure/arm.Dockerfile b/.infrastructure/arm.Dockerfile index 2540c6c..a598ae5 100644 --- a/.infrastructure/arm.Dockerfile +++ b/.infrastructure/arm.Dockerfile @@ -1,16 +1,16 @@ FROM balenalib/armv7hf-alpine:3.12 RUN [ "cross-build-start" ] -RUN apk --update add python3 bash perl curl wget grep sed docker sudo mysql-client postgresql-client make git supervisor tzdata \ +RUN apk --update add python3 bash perl curl wget grep sed docker sudo mysql-client postgresql-client make git tzdata \ sshpass openssh-client RUN [ "cross-build-end" ] ADD . /infracheck ADD .git /infracheck/ -ENV CHECK_INTERVAL="*/1 * * * *" \ - WAIT_TIME=0\ - LAZY=false +ENV REFRESH_TIME="120" \ + WAIT_TIME="0" \ + CHECK_TIMEOUT="10" RUN [ "cross-build-start" ] RUN cd /infracheck \ @@ -34,7 +34,6 @@ RUN cd /infracheck \ RUN [ "cross-build-end" ] ADD /.infrastructure/entrypoint.sh /entrypoint.sh -ADD /.infrastructure/supervisord.conf /etc/supervisord.conf RUN [ "cross-build-start" ] RUN chmod +x /entrypoint.sh diff --git a/.infrastructure/entrypoint.sh b/.infrastructure/entrypoint.sh index 6d5e8d1..70eb051 100644 --- a/.infrastructure/entrypoint.sh +++ b/.infrastructure/entrypoint.sh @@ -22,18 +22,12 @@ prepare_entrypoint () { fi if [[ ${WAIT_TIME} ]]; then - ARGS="${ARGS} --wait${WAIT_TIME} " + ARGS="${ARGS} --wait=${WAIT_TIME} " fi # allow to pass custom arguments from docker run command - echo "#!/bin/bash" > /entrypoint.cmd.sh - echo "infracheck --server-port 8000 ${ARGS} --directory=/data --db-path=/database/db.sqlite3 $@" >> /entrypoint.cmd.sh - - cat /entrypoint.cmd.sh - chmod +x /entrypoint.cmd.sh + echo "infracheck --server-port 8000 ${ARGS} --directory=/data --db-path=/database/db.sqlite3 $@" } prepare_data_directory -prepare_entrypoint "$@" - -exec supervisord -c /etc/supervisord.conf +exec $(prepare_entrypoint "$@") diff --git a/.infrastructure/supervisord.conf b/.infrastructure/supervisord.conf deleted file mode 100644 index d6f32bc..0000000 --- a/.infrastructure/supervisord.conf +++ /dev/null @@ -1,19 +0,0 @@ -[supervisord] -logfile=/var/log/supervisord.log ; supervisord log file -logfile_maxbytes=5MB ; maximum size of logfile before rotation -logfile_backups=2 ; number of backed up logfiles -loglevel=info ; info, debug, warn, trace -nodaemon=true ; run supervisord as a daemon -user=root ; default user -childlogdir=/var/log ; where child log files will live - -[program:cron] -command=/entrypoint.cron.sh -user=root -stdout_events_enabled=true -stderr_events_enabled=true - -[program:infracheck] -command=/entrypoint.cmd.sh -stdout_events_enabled=true -stderr_events_enabled=true diff --git a/.infrastructure/x86_64.Dockerfile b/.infrastructure/x86_64.Dockerfile index 2d03351..c18d3ca 100644 --- a/.infrastructure/x86_64.Dockerfile +++ b/.infrastructure/x86_64.Dockerfile @@ -1,14 +1,14 @@ FROM alpine:3.12 -RUN apk --update add python3 bash perl curl wget grep sed docker sudo mysql-client postgresql-client git supervisor tzdata \ +RUN apk --update add python3 bash perl curl wget grep sed docker sudo mysql-client postgresql-client git tzdata \ sshpass openssh-client ADD . /infracheck ADD .git /infracheck/ ADD .infrastructure /infracheck/ -ENV CHECK_INTERVAL="*/1 * * * *" \ - WAIT_TIME=0\ - LAZY=false +ENV REFRESH_TIME="120" \ + WAIT_TIME="0" \ + CHECK_TIMEOUT="10" RUN cd /infracheck \ # install as a package @@ -30,7 +30,6 @@ RUN cd /infracheck \ && apk del BUILD_DEPS ADD /.infrastructure/entrypoint.sh /entrypoint.sh -ADD /.infrastructure/supervisord.conf /etc/supervisord.conf RUN chmod +x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] diff --git a/docs/source/cache.rst b/docs/source/cache.rst index e06ba98..421eabc 100644 --- a/docs/source/cache.rst +++ b/docs/source/cache.rst @@ -1,33 +1,23 @@ Cache and freshness =================== -It can be harmful to the server to run all checks on each HTTP endpoint call, so a cronjob in background is writing results, and HTTP endpoint is reading. +It can be harmful to the server to run all checks on each HTTP endpoint call, so the application is running them periodically every X seconds specified by **--refresh-time** switch or **REFRESH_TIME** environment variable (in docker) -How often really the checks are performing depends on your configuration, how often you execute **infracheck --force** +Refresh time +------------ ---force -------- +If you use an official docker image, then you can set an environment variable. -The *--force* parameter means that the application will write checks results to a cache. +Example: check once a day (good for domains whois check). -When this flag is not specified, then application will read the data from the cache. +.. code:: bash -Docker ------- + REFRESH_TIME=86400 -If you use an official docker image, then you can set CHECK_INTERVAL to a crontab-like syntax interval eg. **CHECK_INTERVAL=00 23 * * *** to check once a day (good for domains whois check). +From CLI you can set **--refresh-time=86400** -Limits ------- +Wait time +--------- Some checks could call external APIs, those can have limits. A good example is a *domain-expiration* check which is using whois. -It is recommended to run a separate infracheck instance with less frequent checking, eg. once a day - see CHECK_INTERVAL in docker, and crontab in standalone installation. - -You can also use `--wait` switch to set waiting in seconds between single checks (in docker it is `WAIT_TIME` variable) - ---lazy ------- - -When running a ex. HTTP endpoint without `--force`, then application is only reading results of previously executed checks that are usually executed in background using cron. -**Without lazy** the checks that were not executed yet will be showing "Not ready yet" and a **status equals to false**. -If you really need to avoid such case, **then you can allow running a check on-demand by enabling** `--lazy` **flag** (LAZY=true in docker). +Set **--wait=60** to for example wait 60 seconds before each check - where check is a single entry on the list of checks. diff --git a/docs/source/first-steps.rst b/docs/source/first-steps.rst index e86a423..655afd6 100644 --- a/docs/source/first-steps.rst +++ b/docs/source/first-steps.rst @@ -98,14 +98,14 @@ The image will by default expose a HTTP endpoint. # create directory structure that will be present in "/data" inside container (see one of previous steps about the structure) mkdir checks configured - sudo docker run --name infracheck -p 8000:8000 -v $(pwd):/data -d --rm quay.io/riotkit/infracheck:v1.9.1-x86_64 \ + sudo docker run --name infracheck -p 8000:8000 -v $(pwd):/data -d --rm quay.io/riotkit/infracheck:v2.0-x86_64 \ --directory=/data --server-path-prefix=/your-secret-code-there # now test it curl http://localhost:8000/your-secret-code-there/ -List of supported environment variables: +**List of supported environment variables:** - REFRESH_TIME=120 - CHECK_TIMEOUT=120 @@ -123,7 +123,7 @@ List of supported environment variables: infracheck --directory=/your-project-directory-path-there --no-server # run the application with webserver and background worker - infracheck --directory=/your-project-directory-path-there --server-port=7422 --refresh-time=120 --log-level=info + infracheck --directory=/your-project-directory-path-there --server-port=8000 --refresh-time=120 --log-level=info **Using PIP** @@ -136,7 +136,7 @@ List of supported environment variables: infracheck --directory=/your-project-directory-path-there --no-server # run the application with webserver and background worker - infracheck --directory=/your-project-directory-path-there --server-port=7422 --refresh-time=120 --log-level=info + infracheck --directory=/your-project-directory-path-there --server-port=8000 --refresh-time=120 --log-level=info Advanced diff --git a/docs/source/reference.rst b/docs/source/reference.rst index b25b14b..0600c35 100644 --- a/docs/source/reference.rst +++ b/docs/source/reference.rst @@ -29,6 +29,43 @@ Parameters: - expect_keyword - not_expect_keyword +rkd:// +------ + +Infracheck can execute RiotKit-Do tasks. RKD is a task executor, similar to Makefile or Gradle. +It's essential feature is a possibility to load tasks from PyPI (Python packages). + + +Using RKD you can write a Python class, version and release it to PyPI with a list of dependencies, and install in any place +with PIP. A packaged task can require extra dependencies you do not want always to install eg. MySQL, PostgreSQL, Redis or other clients +you want to selectively install on your Infracheck instances. + +More information on how to write RKD tasks: `in RiotKit-Do's documentation `_ + + +.. code:: json + + { + "type": "rkd://rkd.standardlib.shell:sh", + "input": { + "-c": "ps aux |grep X11" + } + } + + +.. code:: json + + { + "type": "rkd://my_rkd_check:mysql:temporary-table-size-check", + "input": { + "--max": "100000", + "--host: "localhost", + "--port": 3306, + "--user": "infracheck", + "--password": "${TEMP_TABLE_SIZE_CHECK_PASSWORD}" + } + } + dir-present ----------- diff --git a/infracheck/checks/domain-expiration b/infracheck/checks/domain-expiration index ce2a700..f0e458d 100755 --- a/infracheck/checks/domain-expiration +++ b/infracheck/checks/domain-expiration @@ -9,7 +9,7 @@ Check if the domain is close to expiration date or if it is already expired. **Notice: Multiple usage of this check can cause a "request limit exceeded" error to happen** -*Suggestion: If you check multiple domains, then separate domains checking from regular health checks and set CHECK_INTERVAL (docker) to once a day, and WAIT_TIME=300 for non-docker installations - in crontab set a check with --force once a day* +*Suggestion: If you check multiple domains, then separate domains checking from regular health checks and set REFRESH_TIME (docker) to once a day, and WAIT_TIME=300 for non-docker installations - in crontab set a check with --force once a day* Parameters: