/belayer-webapi

Web Administration API for tsurugidb.

Primary LanguageJavaApache License 2.0Apache-2.0

Belayer

  1. Web API
  2. Belayer Server Docker Image
  3. Create Distributions
  4. Installing Distributions

1. WebApi

Requirement

  • Java11

How to build

And build with gradle.

$ cd webapi
$ ./gradlew clean build -x test

How to execute

$ cd webapi
$ java -jar build/libs/belayer-webapi-x.x.x.jar

Ctrl-C to shutdown.

How to access

  • API

    $ curl http://localhost:8000/api/hello
  • Health Check

    $ curl http://localhost:18000/management/health

Application Settings

You can configure the Belayer Server with environment variables. See the env var table below.

Environment Variable Description Default Value
(used when variable is not defined)
BELAYER_SERVER_PORT server port for this web application. 8000
BELAYER_MANAGEMENT_PORT management port for this web application. 18000
BELAYER_LOG_LEVEL Log level for belaer WebAPI Server. WARN
BELAYER_STORAGE_ROOT The directory path to use as Belayer storage. /opt/belayer/storage
TSURUGI_URL URL to connect Tsurugi database. tcp://localhost:12345/
TSURUGI_CONNECT_TIMEOUT_SEC connect timeout seconds for Tsurugi database. 5
TSURUGI_SESSION_TIMEOUT_MIN session timeout minutes for Tsurugi database. 15
TSURUGI_HOME Tsurugi HOME directory. /usr/lib/tsurugi
TSURUGI_CONF Tsurugi configuration file path. ${TSURUGI_HOME}/var/etc/tsurugi.ini
TSURUGI_AUTH_URL URL for authentication server "harinoki". http://localhost:8080/harinoki
TSURUGI_AUTH_AT_EXPIRATION_MIN The expiration minutes for Access Token. 10
BELAYER_MAX_FILE_LIST_SIZE Max size to list the files. 500
BELAYER_JOB_EXPIRATION_DAYS Epiration days for the job history data. 3
BELAYER_DL_ZIP_COMPRESS_LEVEL Zip compress level to download the all file contents in the specified directory.
(0-9 or -1 as default)
-1(default compress level)
BELAYER_BK_ZIP_COMPRESS_LEVEL Zip compress level to archive back up files.
(0-9 or -1 as default)
-1(default compress level)
BELAYER_ADMIN_PAGE_ENABLED Serve WebAdmin Contents.(optional, not supported as default) false
BELAYER_ADMIN_PAGE_PATH WebAdmin page path. /admin
BELAYER_WEBADMIN_LOCATION Path to WebAdmin Contents.(optional, not supported as default) file://dev/null

How to use mock Authentication for development

  • Launch Java process with the profile option.
    • java -Dspring.profiles.active=authmock -jar path/to/belayer.jar
  • You can use dummy users defined as uid=password in webapi/src/main/resources/application-authmock.properties

2. Belayer Server Docker Image

How to build Belayer Server Docker Image

  1. pull Tsurugi Docker image
$ sudo docker pull ghcr.io/project-tsurugi/tsurugidb:latest
  1. Start Server and Step in Docker Container.
$ docker-compose up -d
$ docker-compose exec server bash

3. Create Distributions

Requirement

See requirements to build each components.

How to create Belayer Distributions.

$ cd distribution
$ sh create_archives.sh

The distribution files will be in the following directory.

  • distribution/dist
$ ls dist
tsurugi-webapp-x.x.x.tar.gz
  • tsurugi-webapp-x.x.x.tar.gz
    • WebAPI Server(without WebAdmin Page), installation scripts, etc.

4. Installing Distributions

WebAPI

Install to the default directory.

$ tar -zxvf tsurugi-webapp-x.x.x.tar.gz
$ cd tsurugi-webapp-x.x.x
$ sudo sh install.sh

Belayer Web API Server is installed under /usr/lib.

$ ls /usr/lib/tsurugi-webapp-*
tsurugi-webapp-x-x-x

Execute /usr/lib/tsurugi-webapp-x-x-x/bin/start_server.sh to start belayer server.

Install to another directory.

You can specify install directory using --prefix option.

$ tar -zxvf tsurugi-webapp-x.x.x.tar.gz
$ cd tsurugi-webapp-x.x.x
$ sh install.sh --prefix=$HOME/tsurugi-webapp
$ ls $HOME/tsurugi-webapp/*
tsurugi-webapp-x-x-x

Execute <your_prefix>/bin/start_server.sh to start belayer server.