mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-11 18:51:31 +00:00
Merge branch 'app-packaging' into 'develop'
packaging and installation scripts Closes #2 See merge request signalytic/client-external/streamline/streamline-emr!1
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
build-packages
|
||||||
@@ -1,93 +1,82 @@
|
|||||||
# Streamline Emr
|
# Streamline EMR
|
||||||
|
|
||||||
|
Packaging and installation tools for Streamline's "Streamline EMR" application.
|
||||||
|
|
||||||
|
## Building
|
||||||
|
1. ensure you have docker access to this project's container registry on GitLab
|
||||||
|
2. run `package.sh` to generate a new application package
|
||||||
|
3. package will be stored to `build-packages/`
|
||||||
|
|
||||||
## Getting started
|
### Alternative Builds
|
||||||
|
Some variables can be overridden to support alternative builds. For example, an option exists to package the application WITHOUT docker images. This can be done by setting the appropriate environment variables (e.g. `VAR=VALUE ./package.sh`).
|
||||||
|
|
||||||
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
Options that can be overridden are:
|
||||||
|
- `PACKAGE_NAME`: base name of the output package. (default: `streamline-emr`)
|
||||||
|
- `OUTPUT_DIR`: directory where packages will be stored. (default: `$PROJECT_ROOT/build-packages`)
|
||||||
|
- `PACKAGE_IMAGES`: if set to a value other than 1, do NOT package images. (default: `1`)
|
||||||
|
|
||||||
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
## Installing
|
||||||
|
1. extract the generated archive file in a temporary folder on the target system
|
||||||
## Add your files
|
2. run `<package-name>/install.sh`
|
||||||
|
3. add a `instance.conf` file at the root of the install directory (see notes below)
|
||||||
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
4. (optional) restart the systemd service if running on a system with systemd installed: `systemctl restart streamline-emr`
|
||||||
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
5. (optional) configure an `app.conf` file for integration with Signalytic services (e.g. dbsync)
|
||||||
|
|
||||||
|
## Running
|
||||||
|
### Production (systemd)
|
||||||
|
On a production system, `systemd` will manage the lifecycle of the application, e.g.
|
||||||
```
|
```
|
||||||
cd existing_repo
|
# enable and start the the application service
|
||||||
git remote add origin https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
|
systemctl daemon-reload
|
||||||
git branch -M main
|
systemctl enable streamline-emr
|
||||||
git push -uf origin main
|
systemctl start streamline-emr
|
||||||
|
|
||||||
|
# stop the application service
|
||||||
|
systemctl stop streamline-emr
|
||||||
|
|
||||||
|
# restart the application service
|
||||||
|
systemctl restart streamline-emr
|
||||||
```
|
```
|
||||||
|
|
||||||
## Integrate with your tools
|
## Monitoring
|
||||||
|
The script `monitor` can be used at any time to query the current status of all instances. If the `bgsystemlog` program is found, status data will be written to the Signalytic system log under the `streamline_emr` location (json format).
|
||||||
|
|
||||||
- [ ] [Set up project integrations](https://gitlab.com/signalytic/client-external/streamline/streamline-emr/-/settings/integrations)
|
### Docker
|
||||||
|
In a docker environment, the application must be started manually. This is done by running the `entry` script, for example:
|
||||||
|
```
|
||||||
|
/var/signalytic/clientapps/streamline/streamline-emr/entry
|
||||||
|
```
|
||||||
|
Note that the entry script will block until the first service stops or until interrupted.
|
||||||
|
|
||||||
## Collaborate with your team
|
If multiple instances are run from the same machine, additional configuration may be required to differentiate the instances. This is generally the case when using the "sibling container" method for running docker from within a docker container. See the `Configuration` section for more details.
|
||||||
|
|
||||||
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
## Configuration
|
||||||
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
Certain configuration options can be adjusted by setting environment variables or by defining these variables in a `.env` file stored in the same directory as the `docker-compose.yml` file. These variables are:
|
||||||
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
`APP_PORT`: port mapping for the web app server
|
||||||
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
`CONTAINER_NAME`: name of the application container
|
||||||
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
`DATA_DIR`: directory to be mounted for peristant data
|
||||||
|
`COMPOSE_PROJECT_NAME`: assign the project name associate with the compose file - this avoids conflicts when the "same" compose file is used to manage multiple instances (e.g. when using docker sibling containers)
|
||||||
|
`IMAGE`: optional, overrides the default `streamline-emr:2.0` image
|
||||||
|
|
||||||
## Test and Deploy
|
Each instance of the app uses its own `.env` file to specify its configuration. This is automated through the `start` script using information stored in a file `instances.conf`. This file defines two lists:
|
||||||
|
`INSTANCES`: a list of unique instance names
|
||||||
|
`APP_PORTS`: a corresponding list of port numbers to map to the local host
|
||||||
|
|
||||||
Use the built-in continuous integration in GitLab.
|
Important note when using "sibling containers": the sibling container method uses the host docker socket to provide containers with access to docker. As a result, port mappings and volume mount points all refer to the host system rather than the container from which the docker command originates.
|
||||||
|
|
||||||
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
### Example Configuration Files
|
||||||
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
The following snippet shows an `instances.conf` file with 3 instances defined. Instance `test0001-_default` will use port `3001`, `test0002-_default` will use `3002`, etc.
|
||||||
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
```
|
||||||
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
INSTANCES="test0001-_default" "test0002-_default" "test0003-_default"
|
||||||
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
APP_PORTS=3001 3002 3003
|
||||||
|
```
|
||||||
|
|
||||||
***
|
### App Configuration
|
||||||
|
An `app.conf` file is required for integration with other Signalytic services. A template is provided which demonstrates integration with the `dbsync` service.
|
||||||
|
|
||||||
# Editing this README
|
## Scripts
|
||||||
|
Several scripts are used to manage app instances, including:
|
||||||
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
`entry`: main entry script used to start all configured instances - does not return until a service stops or the process is interrupted.
|
||||||
|
`start`: loads configuration details from `instances.conf`, then configures and starts each application instance in a dedicated subfolder
|
||||||
## Suggestions for a good README
|
`stop`: locates and stops all instances, even if no longer defined in `instances.conf`
|
||||||
|
`monitor`: checks the status of each instance service and sends data to `bgsystemlog` if possible (loc: `streamline_emr`)
|
||||||
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
||||||
|
|
||||||
## Name
|
|
||||||
Choose a self-explaining name for your project.
|
|
||||||
|
|
||||||
## Description
|
|
||||||
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
||||||
|
|
||||||
## Badges
|
|
||||||
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
||||||
|
|
||||||
## Visuals
|
|
||||||
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
||||||
|
|
||||||
## Support
|
|
||||||
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
||||||
|
|
||||||
## Roadmap
|
|
||||||
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
||||||
|
|
||||||
## Contributing
|
|
||||||
State if you are open to contributions and what your requirements are for accepting them.
|
|
||||||
|
|
||||||
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
||||||
|
|
||||||
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
||||||
|
|
||||||
## Authors and acknowledgment
|
|
||||||
Show your appreciation to those who have contributed to the project.
|
|
||||||
|
|
||||||
## License
|
|
||||||
For open source projects, say how it is licensed.
|
|
||||||
|
|
||||||
## Project status
|
|
||||||
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
streamline-emr:2.0=registry.gitlab.com/signalytic/client-external/streamline/streamline-emr/arm64:2.0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
streamline-emr:2.0=registry.gitlab.com/signalytic/client-external/streamline/streamline-emr/amd64:2.0
|
||||||
Executable
+51
@@ -0,0 +1,51 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright (C) Wendepunkt Medical Innovations, Inc - All Rights Reserved.
|
||||||
|
# Unauthorized copying of this file, via any medium is strictly prohibited.
|
||||||
|
# Proprietary and confidential
|
||||||
|
#
|
||||||
|
# For information: dev@signalytic.ca
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Install the Streamline "Streamline EMR" application and services
|
||||||
|
#
|
||||||
|
# The caller of this script must check the exit value and possibly do a
|
||||||
|
# roll-back if it is non-zero. If the exit value is non-zero services have not
|
||||||
|
# been restarted.
|
||||||
|
|
||||||
|
LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
|
||||||
|
if [ "$EUID" -ne 0 ]
|
||||||
|
then echo "Please run as root"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# stop any running systemd service if not running in a docker environment
|
||||||
|
if [ -f /.dockerenv ]; then
|
||||||
|
echo "Docker environment detected - skipping systemd installation"
|
||||||
|
else
|
||||||
|
echo "stopping system service"
|
||||||
|
systemctl stop streamline-emr
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# copy root files
|
||||||
|
echo "importing root files"
|
||||||
|
cp -rfv $LOCATION/root/* /
|
||||||
|
|
||||||
|
# import docker images
|
||||||
|
for f in $(find $LOCATION/images -name "*.img" 2>/dev/null);do
|
||||||
|
echo "importing docker image: $f"
|
||||||
|
docker load -i $f
|
||||||
|
done
|
||||||
|
|
||||||
|
# install systemd service unless running in a docker environment
|
||||||
|
if [ ! -f /.dockerenv ]; then
|
||||||
|
echo "installing system service"
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable streamline-emr
|
||||||
|
systemctl start streamline-emr
|
||||||
|
fi
|
||||||
Executable
+123
@@ -0,0 +1,123 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (C) Wendepunkt Medical Innovations, Inc - All Rights Reserved.
|
||||||
|
# Unauthorized copying of this file, via any medium is strictly prohibited.
|
||||||
|
# Proprietary and confidential
|
||||||
|
#
|
||||||
|
# For information: dev@signalytic.ca
|
||||||
|
#
|
||||||
|
|
||||||
|
# basic path info
|
||||||
|
LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
PROJECT_ROOT="$(realpath $LOCATION)"
|
||||||
|
|
||||||
|
# configurable options (override with env vars as needed)
|
||||||
|
PACKAGE_NAME=${PACKAGE_NAME-"streamline-emr"}
|
||||||
|
OUTPUT_DIR=${OUTPUT_DIR-"$PROJECT_ROOT/build-packages"}
|
||||||
|
PACKAGE_IMAGES=${PACKAGE_IMAGES:-1}
|
||||||
|
|
||||||
|
echo "packaging $PACKAGE_NAME"
|
||||||
|
echo " output dir: $OUTPUT_DIR"
|
||||||
|
echo " package images: $PACKAGE_IMAGES"
|
||||||
|
|
||||||
|
# work from the project root
|
||||||
|
pushd $PROJECT_ROOT > /dev/null
|
||||||
|
|
||||||
|
# Exit on error:
|
||||||
|
set -e
|
||||||
|
trap 'echo "Error: Last command failed with exit code $?."' ERR
|
||||||
|
|
||||||
|
# generate version name
|
||||||
|
# use ci tag name if available (e.g. "v1.2")
|
||||||
|
if [ $CI_COMMIT_TAG ]; then
|
||||||
|
VERSION_NAME="$CI_COMMIT_TAG"
|
||||||
|
|
||||||
|
# otherwise if ci, use BRANCH-COMMIT
|
||||||
|
# Note: commit count is harder to get to from CI - can't reproduce the git
|
||||||
|
# describe functionality as easily
|
||||||
|
elif [ $CI_COMMIT_BRANCH ]; then
|
||||||
|
VERSION_NAME="$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA"
|
||||||
|
|
||||||
|
# if not ci, try to use git
|
||||||
|
elif command -v git &> /dev/null; then
|
||||||
|
VERSION_NAME=$(git describe --always --tags --dirty)
|
||||||
|
|
||||||
|
# fallback
|
||||||
|
else
|
||||||
|
VERSION_NAME="unknown"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# build for each relevant platform
|
||||||
|
for platform in "linux/amd64" "linux/arm64"; do
|
||||||
|
echo "preparing package for platform $platform"
|
||||||
|
if [ "$platform" == "linux/amd64" ];then
|
||||||
|
pkg_arch="x86_64"
|
||||||
|
elif [ "$platform" == "linux/arm64" ];then
|
||||||
|
pkg_arch="aarch64"
|
||||||
|
else
|
||||||
|
echo "unexpected platform '$platform'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
OUTPUT_NAME="$PACKAGE_NAME-$VERSION_NAME-${pkg_arch}"
|
||||||
|
OUTPUT_FILE="$OUTPUT_NAME.tar.bz2"
|
||||||
|
OUTPUT_PATH="$OUTPUT_DIR/$OUTPUT_FILE"
|
||||||
|
|
||||||
|
# create a new temp directory to stage files
|
||||||
|
for i in {1..9999};do
|
||||||
|
STAGING_DIR="tmp-staging-$i"
|
||||||
|
if [ ! -d $STAGING_DIR ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ -d $STAGING_DIR ]; then
|
||||||
|
echo "Failed to generate temp staging dir"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# add files
|
||||||
|
PACKAGE_ROOT=${STAGING_DIR}/${OUTPUT_NAME}
|
||||||
|
IMAGES_DIR=${PACKAGE_ROOT}/images
|
||||||
|
mkdir -p ${IMAGES_DIR}
|
||||||
|
cp ${PROJECT_ROOT}/install.sh ${PACKAGE_ROOT}/
|
||||||
|
cp -a ${PROJECT_ROOT}/root ${PACKAGE_ROOT}/
|
||||||
|
echo "${VERSION_NAME}" > ${PACKAGE_ROOT}/root/var/signalytic/clientapps/streamline/streamline-emr/version
|
||||||
|
|
||||||
|
if [ "${PACKAGE_IMAGES}" = "1" ]; then
|
||||||
|
# add images
|
||||||
|
i=0
|
||||||
|
# read image list from file (e.g. 'images-aarch64')
|
||||||
|
# images are listed as SAVED_TAG=SOURCE_IMAGE
|
||||||
|
for image in $(cat ${PROJECT_ROOT}/images-${pkg_arch});do
|
||||||
|
i=$((i+1))
|
||||||
|
name="image${i}.img"
|
||||||
|
path="${IMAGES_DIR}/${name}"
|
||||||
|
IFS=\= read -r dest source <<< "${image}"
|
||||||
|
echo "pulling image '${source}' (${platform})"
|
||||||
|
docker pull --platform ${platform} ${source}
|
||||||
|
echo "tagging image as '${dest}'"
|
||||||
|
docker tag ${source} ${dest}
|
||||||
|
echo "saving to '${path}'"
|
||||||
|
docker save -o ${path} $dest
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "skipping image packaging as requested"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# setup output directory and cleanup old files if necessary
|
||||||
|
mkdir -p $OUTPUT_DIR
|
||||||
|
rm -rf $OUTPUT_PATH
|
||||||
|
|
||||||
|
pushd $STAGING_DIR > /dev/null
|
||||||
|
tar -cjf $OUTPUT_PATH ${OUTPUT_NAME}
|
||||||
|
popd > /dev/null
|
||||||
|
|
||||||
|
# cleanup staging files
|
||||||
|
rm -r $STAGING_DIR
|
||||||
|
|
||||||
|
echo "output: $OUTPUT_PATH"
|
||||||
|
done
|
||||||
|
|
||||||
|
popd > /dev/null
|
||||||
|
|
||||||
|
exit 0
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Run Streamline EMR
|
||||||
|
After=network.target
|
||||||
|
StartLimitIntervalSec=0
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
Restart=always
|
||||||
|
RestartSec=10
|
||||||
|
User=root
|
||||||
|
ExecStart=/var/signalytic/clientapps/streamline/streamline-emr/entry
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
version: '3.9'
|
||||||
|
services:
|
||||||
|
streamline-emr:
|
||||||
|
image: ${IMAGE:-streamline-emr:2.0}
|
||||||
|
container_name: ${CONTAINER_NAME}
|
||||||
|
volumes:
|
||||||
|
- "${DATA_DIR}:/var/lib/mysql"
|
||||||
|
ports:
|
||||||
|
- "${APP_PORT}:80"
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
|
||||||
|
function cleanup {
|
||||||
|
${LOCATION}/stop
|
||||||
|
echo "done."
|
||||||
|
}
|
||||||
|
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
# start all instances
|
||||||
|
${LOCATION}/start
|
||||||
|
|
||||||
|
# wait for any service to stop
|
||||||
|
pids=()
|
||||||
|
for f in $(find ${LOCATION} -mindepth 2 -maxdepth 3 -name docker-compose.yml); do
|
||||||
|
pushd $(dirname $f) > /dev/null
|
||||||
|
docker compose wait streamline-emr &
|
||||||
|
pids+=($!)
|
||||||
|
popd > /dev/null
|
||||||
|
done
|
||||||
|
echo "waiting on processes: ${pids[@]}"
|
||||||
|
wait -n ${pids[@]} > /dev/null
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
|
||||||
|
for f in $(find ${LOCATION} -mindepth 2 -maxdepth 3 -name docker-compose.yml); do
|
||||||
|
pushd $(dirname $f) > /dev/null
|
||||||
|
status=$(docker compose ps --format '{"name":"{{.Names}}","created":"{{.CreatedAt}}","elapsed":"{{.RunningFor}}","state":"{{.State}}","status":"{{.Status}}"}')
|
||||||
|
popd > /dev/null
|
||||||
|
if [ "${status}" ]; then
|
||||||
|
echo $status
|
||||||
|
if command -v bgsystemlog &> /dev/null
|
||||||
|
then
|
||||||
|
bgsystemlog -j streamline_emr -m "'${status}'"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "no services found"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "done."
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
|
||||||
|
CONF_FILE=${LOCATION}/instances.conf
|
||||||
|
INSTANCES_DIR=${LOCATION}/instances
|
||||||
|
COMPOSE_FILE=${LOCATION}/docker-compose.yml
|
||||||
|
ENV_TEMPLATE=${LOCATION}/template.env
|
||||||
|
VERSION_FILE=${LOCATION}/version
|
||||||
|
|
||||||
|
version=$(head -n 1 ${VERSION_FILE} 2>/dev/null)
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
version="unknown version"
|
||||||
|
fi
|
||||||
|
echo "Starting Streamline EMR: $version"
|
||||||
|
|
||||||
|
if [ ! -f "${CONF_FILE}" ]; then
|
||||||
|
echo "missing conf file: ${CONF_FILE}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "processing config file: ${CONF_FILE}"
|
||||||
|
|
||||||
|
# load instance names and port numbers from conf file
|
||||||
|
instances=($(sed -n "s/INSTANCES=//p" ${CONF_FILE}))
|
||||||
|
ports=($(sed -n "s/APP_PORTS=//p" ${CONF_FILE}))
|
||||||
|
for ((i=0;i<${#instances[@]};i++)); do
|
||||||
|
|
||||||
|
# prepare directory and config files for instance
|
||||||
|
instance=$(echo ${instances[$i]} | tr -d '"')
|
||||||
|
port=$(echo ${ports[$i]} | tr -d '"')
|
||||||
|
echo
|
||||||
|
echo "configuring instance $((i+1)) / ${#instances[@]}"
|
||||||
|
echo " name: ${instance}"
|
||||||
|
echo " port: ${port}"
|
||||||
|
mkdir -p ${INSTANCES_DIR}/${instance}/data
|
||||||
|
sed -e "s/{{INSTANCE_NAME}}/${instance}/g" -e "s/{{INSTANCE_PORT}}/${port}/g" ${ENV_TEMPLATE} > ${INSTANCES_DIR}/${instance}/.env
|
||||||
|
cp ${COMPOSE_FILE} ${INSTANCES_DIR}/${instance}/
|
||||||
|
|
||||||
|
# start app
|
||||||
|
pushd ${INSTANCES_DIR}/${instance} > /dev/null
|
||||||
|
docker compose up -d --force-recreate
|
||||||
|
popd > /dev/null
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "done."
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
|
||||||
|
echo "stopping all instances"
|
||||||
|
for f in $(find ${LOCATION} -mindepth 2 -maxdepth 3 -name docker-compose.yml); do
|
||||||
|
pushd $(dirname $f) > /dev/null
|
||||||
|
docker compose down
|
||||||
|
popd > /dev/null
|
||||||
|
done
|
||||||
|
echo "done."
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "Streamline EMR",
|
||||||
|
"dbsync": {
|
||||||
|
"database": {
|
||||||
|
"type": "mysql",
|
||||||
|
"version": "8.0.23",
|
||||||
|
"name": "main",
|
||||||
|
"username": "",
|
||||||
|
"password": "",
|
||||||
|
"db_path": "/var/lib/mysql",
|
||||||
|
"logs_path": "/var/lib/mysql/logs",
|
||||||
|
"log_pattern": "binlog.[0-9]*"
|
||||||
|
},
|
||||||
|
"blockgraph": {
|
||||||
|
"district": "",
|
||||||
|
"name": "",
|
||||||
|
"username": "",
|
||||||
|
"password": ""
|
||||||
|
},
|
||||||
|
"instances": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
COMPOSE_PROJECT_NAME={{INSTANCE_NAME}}
|
||||||
|
CONTAINER_NAME=streamline-emr-{{INSTANCE_NAME}}
|
||||||
|
DATA_DIR=/var/signalytic/clientapps/streamline/streamline-emr/instances/{{INSTANCE_NAME}}/data
|
||||||
|
APP_PORT={{INSTANCE_PORT}}
|
||||||
|
#IMAGE=streamline-emr:2.0
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
INSTANCES=
|
||||||
|
APP_PORTS=
|
||||||
Reference in New Issue
Block a user