Skip to content

Commit

Permalink
Refactor placement of helper and installation files (closes #40)
Browse files Browse the repository at this point in the history
Moved helper scripts
Moved topology diagrams
Updated installation scripts
  • Loading branch information
jbeemster committed Apr 5, 2016
1 parent 63e2d5c commit 1f078c2
Show file tree
Hide file tree
Showing 16 changed files with 115 additions and 22 deletions.
12 changes: 9 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ services:
before_script:
- sudo adduser ubuntu --disabled-password --gecos ""
- sudo passwd -d ubuntu
- sudo ./scripts/setup_dirs.sh
- sudo ./scripts/1_setup_dirs_pipes.sh
- sudo cp -rf ./resources/elasticsearch /home/ubuntu/snowplow
- sudo ./scripts/provision.sh
- sudo ./scripts/3_setup_apps.sh
- sudo cp -rf ./resources/configs /home/ubuntu/snowplow
- sudo cp -rf ./scripts /home/ubuntu/snowplow
- sudo cp -rf ./resources/init /home/ubuntu/snowplow
- sudo ./scripts/setup_init.sh
- sudo cp -rf ./ui/index.html /home/ubuntu/snowplow/ui
- sudo cp -rf ./ui/dist/bundle.js /home/ubuntu/snowplow/ui/dist
- sudo cp -rf ./ui/node_modules /home/ubuntu/snowplow/ui
- sudo cp -rf ./ui/assets /home/ubuntu/snowplow/ui
- sudo ./scripts/4_setup_ui.sh
- sudo ./scripts/5_setup_init.sh
- sudo ./scripts/6_configure.sh

script:
- ./integration/integration_test.sh
38 changes: 34 additions & 4 deletions Packerfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"provisioners": [
{
"type": "shell",
"script": "scripts/setup_dirs.sh",
"script": "scripts/1_setup_dirs_pipes.sh",
"execute_command": "chmod +x {{ .Path }}; sh '{{ .Path }}'"
},
{
Expand All @@ -28,12 +28,12 @@
},
{
"type": "shell",
"script": "scripts/setup_postgres.sh",
"script": "scripts/2_setup_postgres.sh",
"execute_command": "chmod +x {{ .Path }}; sh '{{ .Path }}'"
},
{
"type": "shell",
"script": "scripts/provision.sh",
"script": "scripts/3_setup_apps.sh",
"execute_command": "chmod +x {{ .Path }}; sh '{{ .Path }}'"
},
{
Expand All @@ -51,9 +51,39 @@
"source": "resources/init",
"destination": "/home/ubuntu/snowplow"
},
{
"type": "file",
"source": "ui/index.html",
"destination": "/home/ubuntu/snowplow/ui/index.html"
},
{
"type": "file",
"source": "ui/dist/bundle.js",
"destination": "/home/ubuntu/snowplow/ui/dist/bundle.js"
},
{
"type": "file",
"source": "ui/assets",
"destination": "/home/ubuntu/snowplow/ui"
},
{
"type": "file",
"source": "ui/node_modules",
"destination": "/home/ubuntu/snowplow/ui"
},
{
"type": "shell",
"script": "scripts/4_setup_ui.sh",
"execute_command": "chmod +x {{ .Path }}; sh '{{ .Path }}'"
},
{
"type": "shell",
"script": "scripts/5_setup_init.sh",
"execute_command": "chmod +x {{ .Path }}; sh '{{ .Path }}'"
},
{
"type": "shell",
"script": "scripts/setup_init.sh",
"script": "scripts/6_configure.sh",
"execute_command": "chmod +x {{ .Path }}; sh '{{ .Path }}'"
}
]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Snowplow-Mini runs several distinct applications on the same box which are all l

These events can then be viewed at port `5601` in Kibana.

![](https://raw.githubusercontent.com/snowplow/snowplow-mini/release/0.2.0/topology/snowplow-mini-topology.jpg)
![](https://raw.githubusercontent.com/snowplow/snowplow-mini/release/0.2.0/resources/topology/snowplow-mini-topology.jpg)

## Roadmap

Expand Down
2 changes: 2 additions & 0 deletions integration/integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ sudo service snowplow_stream_collector_0.6.0 start
sudo service snowplow_stream_enrich_0.7.0 start
sudo service snowplow_elasticsearch_sink_good_0.5.0 start
sudo service snowplow_elasticsearch_sink_bad_0.5.0 start
sudo service kibana4_init start
sudo service nginx start
sleep 15

# Send good and bad events
Expand Down
10 changes: 10 additions & 0 deletions resources/configs/snowplow-mini.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
server {
listen 80;
root /home/ubuntu/snowplow/ui;
server_name \$hostname;
access_log /var/log/nginx/snowplow-mini.access.log;

location = / {
try_files /index.html /index.html;
}
}
3 changes: 3 additions & 0 deletions resources/init/nginx_passenger
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

sudo /opt/nginx/sbin/nginx
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
2 changes: 2 additions & 0 deletions scripts/setup_dirs.sh → scripts/1_setup_dirs_pipes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ unix_pipes_dir=$main_dir/pipes
es_dir=$main_dir/elasticsearch
scripts_dir=$main_dir/scripts
init_dir=$main_dir/init
ui_dir=$main_dir/ui/dist

# Pipes
raw_events_pipe=$unix_pipes_dir/raw-events-pipe
Expand All @@ -31,6 +32,7 @@ mkdir -p $unix_pipes_dir
mkdir -p $es_dir
mkdir -p $scripts_dir
mkdir -p $init_dir
mkdir -p $ui_dir

mkfifo $raw_events_pipe
mkfifo $enriched_pipe
Expand Down
2 changes: 2 additions & 0 deletions scripts/setup_postgres.sh → scripts/2_setup_postgres.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash -e

# NOTE: Seperated from provision.sh as Travis comes with Postgres

sudo apt-get update
sudo apt-get install -y unzip

Expand Down
19 changes: 8 additions & 11 deletions scripts/provision.sh → scripts/3_setup_apps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ unzip $staging_dir/${kinesis_package} -d $executables_dir

wget http://bintray.com/artifact/download/snowplow/snowplow-generic/${iglu_server_package} -P $staging_dir
unzip $staging_dir/${iglu_server_package} -d $executables_dir
sudo -u postgres psql -c "create user snowplow createdb password 'snowplow';"
sudo -u postgres psql -c "create database iglu owner snowplow;"
sudo -u postgres psql -c "create user snowplow createdb password 'snowplow';" || true
sudo -u postgres psql -c "create database iglu owner snowplow;" || true

#########################
# Install Elasticsearch #
Expand All @@ -61,14 +61,11 @@ wget "https://download.elasticsearch.org/kibana/kibana/kibana-${kibana_v}-linux-
sudo unzip $staging_dir/kibana-${kibana_v}-linux-x64.zip -d /opt/
sudo ln -s /opt/kibana-${kibana_v}-linux-x64 /opt/kibana

sudo chown -R ubuntu:ubuntu $main_dir

################
# Add Mappings #
################
#################
# Install Nginx #
#################

sudo service elasticsearch start
sleep 15
sudo apt-get -y install nginx apache2-dev

curl -XPUT 'http://localhost:9200/good' -d @${es_dir}/good-mapping.json
curl -XPUT 'http://localhost:9200/bad' -d @${es_dir}/bad-mapping.json
# Set ownership of directory
sudo chown -R ubuntu:ubuntu $main_dir
16 changes: 16 additions & 0 deletions scripts/4_setup_ui.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash -e

#############
# Constants #
#############

main_dir=/home/ubuntu/snowplow
configs_dir=$main_dir/configs

############
# Setup UI #
############

sudo rm -f /etc/nginx/sites-enabled/default
sudo cp $configs_dir/snowplow-mini.conf /etc/nginx/conf.d/

6 changes: 3 additions & 3 deletions scripts/setup_init.sh → scripts/5_setup_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ sudo cp $init_dir/iglu_server_0.2.0 /etc/init.d
sudo chmod 0755 /etc/init.d/iglu_server_0.2.0
sudo update-rc.d iglu_server_0.2.0 defaults

## Start iglu_server to ensure apikeys table gets created
sudo service iglu_server_0.2.0 start
sleep 60
sudo cp $init_dir/nginx_passenger /etc/init.d
sudo chmod 0755 /etc/init.d/nginx_passenger
sudo update-rc.d nginx_passenger defaults
25 changes: 25 additions & 0 deletions scripts/6_configure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash -e

#############
# Constants #
#############

main_dir=/home/ubuntu/snowplow
es_dir=$main_dir/elasticsearch

################
# Add Mappings #
################

sudo service elasticsearch start
sleep 15

curl -XPUT 'http://localhost:9200/good' -d @${es_dir}/good-mapping.json
curl -XPUT 'http://localhost:9200/bad' -d @${es_dir}/bad-mapping.json

####################
# Init Iglu Server #
####################

sudo service iglu_server_0.2.0 start
sleep 30

0 comments on commit 1f078c2

Please sign in to comment.