Skip to content

Latest commit

 

History

1,292 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

env-logger

CircleCI

The env-logger is a data logger and visualisation Web application for collecting and displaying various physical environment data, such as, temperature, humidity and light value.

Prerequisites

To build and run this application locally you will need a recent Clojure version installed. Additionally, a PostgreSQL server instance is needed. Database definitions can be found in db-def.sql and a database with the required tables must exist before the application can be started.

Authentication

This application uses OpenID Connect based authentication. Keycloak has been used for development but other OpenID Connect implementations should work as well. See the oid-auth section in the configuration file for the settings to be configured.

Configuration

A sample configuration can be found in the resources/config.edn_sample file. The configuration file used in development is resources/dev/config.edn and the one for production in resources/prod/config.edn. After copying the sample file edit either or both file(s) as needed. Some settings can be overridden with environment variables or by reading from a file. Accepted environment variables are described below.

  • APP_PORT: The port which the application will be accessible through. The default port is 8080.
  • POSTGRESQL_DB_HOST: Hostname of the database server.
  • POSTGRESQL_DB_PORT: The port on which the database server is listening.
  • POSTGRESQL_DB_NAME: Name of the database.
  • POSTGRESQL_DB_USERNAME: Username of the database user.

The database password cannot be set through an environment variable due to security reasons. Instead it can be read from a file whose name is set in the POSTGRESQL_DB_PASSWORD_FILE environment variable. This file must only contain the database password on one line.

Running

Locally

To start the application locally run clojure -M:dev.

When developing frontend chart or auth code, install Node dependencies once and build the browser bundles:

npm install

npm run build:js

For active frontend development, run a bundler in watch mode:

npm run build:chart:watch

npm run build:auth:watch

Frontend tests can be run with:

npm test

Production loads authentication scripts from :static-asset-path. After npm run build:js, upload only these files to that prefix:

  • src/public/js/auth-load.js
  • src/public/js/auth.js (the generated IIFE bundle)

Do not upload auth-logic.js or src/public/js/auth/ as separate scripts; they are bundled into auth.js. chart.bundle.js is served by the application, not from this prefix. If the prefix is date-versioned, point :static-asset-path at the new folder after the upload.

Running tests

Run tests with Kaocha:

clojure -M:test

The :test alias uses resources/config.edn_sample. Kaocha randomisation is enabled by default (from tests.edn). To disable randomisation for a run, use:

clojure -M:test --no-randomize

For local test runs, override database connection settings via environment variables as needed:

  • POSTGRESQL_DB_HOST (for example localhost)
  • POSTGRESQL_DB_PORT
  • POSTGRESQL_DB_USERNAME (for example your local PostgreSQL user)
  • POSTGRESQL_DB_PASSWORD_FILE (optional, if password is read from file)

The test database name is fixed to env_logger_test.

Auth smoke check

Run auth endpoint smoke checks locally:

./scripts/auth-smoke.sh

Optional base URL argument:

./scripts/auth-smoke.sh http://localhost/devsite/

Docker / podman

This application can be also be run in a Docker or Podman container. To build the container call just build from root directory of the application. This requires the just command to be installed. The container will be called env-logger. The .jar file to run in in the container can be executed with the java -jar <name>.jar command.

License

See the MIT license in the LICENSE file.

Copyright © 2014-2022 Tero Paloheimo

About

A data logger application

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages