This repository has been archived by the owner on Apr 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_example
executable file
·61 lines (52 loc) · 1.73 KB
/
run_example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
set -e
# Start consumer on the non-rails application
echo 'Starting non rails application consumer...'
pushd example/non_rails_app >/dev/null
bundle >/dev/null
bundle exec rake
bundle exec rabbit_feed consume --environment development --require `pwd`/lib/non_rails_app.rb --daemon --verbose
sleep 1
popd >/dev/null
echo 'Non rails application consumer started'
# Start consumer on the rails application
echo 'Starting rails application consumer...'
pushd example/rails_app >/dev/null
bundle >/dev/null
bin/rails db:environment:set RAILS_ENV=development
bundle exec rake db:reset
bundle exec rake
bundle exec rabbit_feed consume --environment development --daemon --verbose
sleep 1
popd >/dev/null
echo 'Rails application consumer started'
# Start the rails application
echo 'Starting rails application...'
pushd example/rails_app >/dev/null
bundle exec unicorn -c config/unicorn.rb -D
sleep 1
popd >/dev/null
echo 'Rails application started'
# Trigger an event
echo 'Triggering event...'
curl -silent --data "beaver[name]=`date '+%m/%d/%y %H:%M:%S'`" http://127.0.0.1:8080/beavers >/dev/null
echo 'Event triggered'
sleep 3
# Stop consumer on the non-rails application
echo 'Stopping non rails application consumer...'
pushd example/non_rails_app >/dev/null
kill `cat tmp/pids/rabbit_feed.pid`
popd >/dev/null
echo 'Non rails application consumer stopped'
# Stop consumer on the rails application
echo 'Stopping rails application consumer...'
pushd example/rails_app >/dev/null
kill `cat tmp/pids/rabbit_feed.pid`
popd >/dev/null
echo 'Rails application consumer stopped'
# Stop the rails application
echo 'Stopping rails application...'
pushd example/rails_app >/dev/null
kill `cat tmp/pids/unicorn.pid`
popd >/dev/null
echo 'Rails application stopped'