Skip to content

Commit 4378e8e

Browse files
author
P. Barrett Little
committed
Merge pull request pblittle#21 from pblittle/feature/build-fixes-and-basic-test
Feature/build fixes and basic test
2 parents aa4002a + eb5a053 commit 4378e8e

File tree

5 files changed

+64
-19
lines changed

5 files changed

+64
-19
lines changed

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ MAINTAINER P. Barrett Little <barrett@barrettlittle.com>
55
RUN apt-get update
66

77
# Install dependencies
8-
RUN apt-get install -yq \
8+
RUN DEBIAN_FRONTEND=noninteractive \
9+
apt-get install -yq \
910
openjdk-7-jre-headless \
1011
wget
1112

@@ -23,10 +24,10 @@ RUN /opt/logstash/bin/plugin install contrib
2324
RUN mkdir /app
2425
ADD . /app
2526

26-
# Elasticsearch HTTP port
27+
# Elasticsearch HTTP
2728
EXPOSE 9200
2829

29-
# Elasticsearch transport port
30+
# Elasticsearch transport
3031
EXPOSE 9300
3132

3233
# Kibana

Makefile

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ VERSION = 0.7.0
33

44
# Set the LOGSTASH_CONFIG_URL env var to your logstash.conf file.
55
# We will use our basic config if the value is empty.
6+
#
67
LOGSTASH_CONFIG_URL ?= https://gist.github.com/pblittle/8778567/raw/logstash.conf
78

89
# This default host and port are for using the embedded elasticsearch
@@ -20,12 +21,12 @@ LF_SSL_CERT_URL ?= https://gist.github.com/pblittle/8994726/raw/insecure-logstas
2021

2122
define docker_run_flags
2223
-e LOGSTASH_CONFIG_URL=${LOGSTASH_CONFIG_URL} \
23-
-e LF_SSL_CERT_URL=${LF_SSL_CERT_URL} \
24-
-e LF_SSL_CERT_KEY_URL=${LF_SSL_CERT_KEY_URL} \
2524
-e ES_HOST=${ES_HOST} \
2625
-e ES_PORT=${ES_PORT} \
27-
-p 9292:9292 \
28-
-v /dev/log:/dev/log
26+
-e LF_SSL_CERT_URL=${LF_SSL_CERT_URL} \
27+
-e LF_SSL_CERT_KEY_URL=${LF_SSL_CERT_KEY_URL} \
28+
-p ${ES_PORT}:${ES_PORT} \
29+
-p 9292:9292
2930
endef
3031

3132
ifdef ES_CONTAINER
@@ -40,14 +41,18 @@ build:
4041
run:
4142
docker run -d $(docker_run_flags) --name logstash $(NAME):$(VERSION)
4243

44+
.PHONY: shell
45+
shell:
46+
docker run -t -i --rm $(NAME):$(VERSION) /bin/bash
47+
48+
.PHONY: test
49+
test:
50+
/bin/bash tests/logstash.sh
51+
4352
.PHONY: tag
4453
tag:
4554
docker tag $(NAME):$(VERSION) $(NAME):latest
4655

4756
.PHONY: release
4857
release:
4958
docker push $(NAME)
50-
51-
.PHONY: shell
52-
shell:
53-
docker run -t -i --rm $(NAME):$(VERSION) bash

Vagrantfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ Vagrant.configure('2') do |config|
2424

2525
config.vm.network :private_network, ip: MACHINE_IP
2626
config.vm.network :forwarded_port, guest: 9292, host: 9292
27-
config.vm.network :forwarded_port, guest: 9200, host: 9200
28-
config.vm.network :forwarded_port, guest: 9300, host: 9300
2927

3028
config.vm.synced_folder './', '/vagrant'
3129

bin/boot

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -eo pipefail
88

99
LOGSTASH_CONFIG_FILE="/opt/logstash.conf"
1010

11-
# Download default conf is none present
11+
# Download default conf if none present
1212
if [ ! -f $LOGSTASH_CONFIG_FILE ]; then
1313
# Use the LOGSTASH_CONFIG_URL env var to download and use your
1414
# logstash.conf file.
@@ -20,12 +20,13 @@ if [ ! -f $LOGSTASH_CONFIG_FILE ]; then
2020
LOGSTASH_CONFIG_URL="https://gist.github.com/pblittle/8778567/raw/logstash.conf"
2121
fi
2222

23-
echo "Downloading default configuration file"
23+
echo "Downloading default configuration file ..."
2424
wget $LOGSTASH_CONFIG_URL -O $LOGSTASH_CONFIG_FILE
2525

2626
# This magic will replace ES_HOST and ES_PORT in your logstash.conf
2727
# file if they exist with the IP and port dynamically generated
2828
# by docker. Take a look at the readme for more details.
29+
#
2930
# Note: Don't use this on a file mounting using a docker
3031
# volume, as the inode switch will cause `device or resource busy`
3132
# Instead download your file as normal
@@ -55,7 +56,7 @@ wget $LF_SSL_CERT_KEY_URL -O $LF_SSL_CERT_KEY_FILE
5556

5657
# Fire up logstash!
5758
exec /opt/logstash/bin/logstash \
58-
agent \
59-
--config $LOGSTASH_CONFIG_FILE \
60-
-- \
61-
web
59+
agent \
60+
--config $LOGSTASH_CONFIG_FILE \
61+
-- \
62+
web

tests/logstash.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
function print_pass()
6+
{
7+
echo "Pass: ${1}"
8+
}
9+
10+
function print_fail()
11+
{
12+
echo "Fail: ${1}"
13+
}
14+
15+
port_check=`netstat -an | grep ':9292\|:9200'`
16+
port_status=$?
17+
18+
if [[ $port_status != 0 || $port_check = '' ]]; then
19+
print_fail port_check
20+
else
21+
print_pass port_check
22+
fi
23+
24+
process_check=`ps -ef | grep 'logstash' | grep -v grep`
25+
process_status=$?
26+
27+
if [[ $process_status != 0 || $process_check = '' ]]; then
28+
print_fail process_check
29+
else
30+
print_pass process_check
31+
fi
32+
33+
curl_check=`curl -s -S localhost:9200/_nodes?pretty=true`
34+
curl_status=$?
35+
36+
if [[ $curl_status != 0 || $curl_check = '' ]]; then
37+
print_fail curl_check
38+
else
39+
print_pass curl_check
40+
fi

0 commit comments

Comments
 (0)