Skip to content

Commit c733836

Browse files
Merge pull request #52 from jembi/PLAT-235-logstash-dev-mount
PLAT-235 Logstash dev mount
2 parents f3bf5c2 + d7cb881 commit c733836

File tree

7 files changed

+42
-5
lines changed

7 files changed

+42
-5
lines changed

.env.local

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ KIBANA_SSL=false
4949
# ES_ELASTIC - Required for Logstash, set in the "Analytics Datastore - Elastic Search" section
5050
LS_JAVA_OPTS=-Xmx2g -Xms2g
5151

52+
LOGSTASH_DEV_MOUNT=false
53+
LOGSTASH_PACKAGE_PATH=
54+
5255
# Dashboard Visualiser - JS Report
5356

5457
JS_REPORT_INSTANCES=1

data-mapper-logstash/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Data Mapper - Logstash
2+
3+
## Developing the logstash configs locally
4+
5+
When seeking to make changes to the logstash configs without having to repeatedly start and stop the service, one can set the `LOGSTASH_DEV_MOUNT`
6+
env var in your .env file to `true` to attach the service's config files to those on your local machine.
7+
8+
## Notes
9+
10+
- With `LOGSTASH_DEV_MOUNT=true`, you have to set the `LOGSTASH_PACKAGE_PATH` variable with the absolute path to package containing your Logstash config files, i.e., `LOGSTASH_PACKAGE_PATH=/home/user/Documents/Projects/platform/data-mapper-logstash`.
11+
- WARNING: do not edit the pipeline files from within the logstash container, or the group ID and user ID will change, and subsequently will result in file permission errors on your local file system.

data-mapper-logstash/dev-mnt-logstash.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: '3.9'
2+
3+
services:
4+
data-mapper-logstash:
5+
volumes:
6+
- ${LOGSTASH_PACKAGE_PATH}/pipeline/:/usr/share/logstash/pipeline/
7+
- ${LOGSTASH_PACKAGE_PATH}/pipelines.yml:/usr/share/logstash/config/pipelines.yml

data-mapper-logstash/package-metadata.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"environmentVariables": {
99
"ES_ELASTIC": "${ES_ELASTIC}",
1010
"LS_JAVA_OPTS": "-Xmx2g -Xms2g",
11+
"LOGSTASH_DEV_MOUNT": "false",
12+
"LOGSTASH_PACKAGE_PATH": "",
1113
"LOGSTASH_MEMORY_LIMIT": "3G",
1214
"LOGSTASH_MEMORY_RESERVE": "500M"
1315
},

data-mapper-logstash/swarm.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
Action=$1
55
Mode=$2
66

7+
readonly LOGSTASH_DEV_MOUNT=$LOGSTASH_DEV_MOUNT
8+
79
COMPOSE_FILE_PATH=$(
810
cd "$(dirname "${BASH_SOURCE[0]}")" || exit
911
pwd -P
@@ -61,16 +63,30 @@ else
6163
LogstashDevComposeParam=""
6264
fi
6365

66+
if [[ "$LOGSTASH_DEV_MOUNT" == "true" ]]; then
67+
if [[ -z $LOGSTASH_PACKAGE_PATH ]]; then
68+
echo "ERROR: LOGSTASH_PACKAGE_PATH environment variable not specified. Please specify LOGSTASH_PACKAGE_PATH as stated in the README."
69+
exit 1
70+
fi
71+
72+
echo -e "\nRunning Data Mapper Logstash package with dev mount\n"
73+
LogstashDevMountComposeParam="-c ${COMPOSE_FILE_PATH}/docker-compose.dev-mnt.yml"
74+
else
75+
LogstashDevMountComposeParam=""
76+
fi
77+
6478
if [[ "$Action" == "init" ]] || [[ "$Action" == "up" ]]; then
6579

6680
config::set_config_digests "$COMPOSE_FILE_PATH"/docker-compose.yml
6781

68-
docker stack deploy -c "$COMPOSE_FILE_PATH"/docker-compose.yml $LogstashDevComposeParam instant
82+
docker stack deploy -c "$COMPOSE_FILE_PATH"/docker-compose.yml $LogstashDevComposeParam $LogstashDevMountComposeParam instant
6983

7084
AwaitContainerStartup
7185
AwaitContainerReady
7286

73-
config::copy_shared_configs "$COMPOSE_FILE_PATH"/package-metadata.json /usr/share/logstash/
87+
if [[ "$LOGSTASH_DEV_MOUNT" != "true" ]]; then
88+
config::copy_shared_configs "$COMPOSE_FILE_PATH"/package-metadata.json /usr/share/logstash/
89+
fi
7490

7591
echo "Removing stale configs..."
7692
config::remove_stale_service_configs "$COMPOSE_FILE_PATH"/docker-compose.yml "logstash"

utils/config-utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ config::copy_shared_configs() {
149149

150150
for sharedConfig in "${sharedConfigs[@]}"; do
151151
# TODO: (https://jembiprojects.jira.com/browse/PLAT-252) swap docker copy for a swarm compliant approach
152-
docker cp "${packageBaseDir}""${sharedConfig//\"//}" "${containerId}":"${CONTAINER_DESTINATION}"
152+
docker cp -a "${packageBaseDir}""${sharedConfig//\"//}" "${containerId}":"${CONTAINER_DESTINATION}"
153153
done
154154
}
155155

0 commit comments

Comments
 (0)