Browse Source

Add a Procfile to run the Web and Processors.

Web and Processors are defined as rake tasks.
The overall runner is started with make, using Foreman.
tags/0.3.0^2
Bèr Kessels 2 years ago
parent
commit
1e01ba1be7
6 changed files with 45 additions and 12 deletions
  1. 2
    0
      Gemfile
  2. 4
    0
      Gemfile.lock
  3. 5
    12
      Makefile
  4. 2
    0
      Procfile
  5. 27
    0
      Rakefile
  6. 5
    0
      config.ru

+ 2
- 0
Gemfile View File

@@ -27,4 +27,6 @@ group :development, :test do

gem 'awesome_print'
gem 'better_errors'

gem 'foreman'
end

+ 4
- 0
Gemfile.lock View File

@@ -26,6 +26,8 @@ GEM
sequel (>= 4.38)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
foreman (0.85.0)
thor (~> 0.19.1)
jaro_winkler (1.5.2)
json (2.1.0)
minitest (5.11.3)
@@ -62,6 +64,7 @@ GEM
rack (~> 2.0)
rack-protection (= 2.0.5)
tilt (~> 2.0)
thor (0.19.4)
tilt (2.0.9)
unicode-display_width (1.4.1)

@@ -75,6 +78,7 @@ DEPENDENCIES
dotenv (~> 2.6)
event_sourcery
event_sourcery-postgres
foreman
minitest
nominatim!
opening_hours_converter

+ 5
- 12
Makefile View File

@@ -1,26 +1,15 @@
OUT_DIR=tmp
CMD_PREFIX=bundle exec
VERSION=$(shell semver)
TODAY=$(shell date +%F)
include .env

# You want latexmk to *always* run, because make does not have all the info.
# Also, include non-file targets in .PHONY so they are run regardless of any
# file of the given name existing.
.PHONY: all test lint clean setup ruby packages preprocess install migrate
.PHONY: all test lint clean setup ruby packages preprocess run

# The first rule in a Makefile is the one executed by default ("make"). It
# should always be the "all" rule, so that "make" and "make all" are identical.
all: test lint

install:
docker run --name pbx_$(DB_NAME) -e POSTGRES_PASS=$(DB_PASSWORD) -e POSTGRES_USER=$(DB_USER) -p5432:$(DB_PORT) -d -t kartoza/postgis

database:
$(CMD_PREFIX) rake db:drop
$(CMD_PREFIX) rake db:create
$(CMD_PREFIX) rake db:migrate

# CUSTOM BUILD RULES
test:
$(CMD_PREFIX) ruby -I lib:test:. -e "Dir.glob('**/*_test.rb') { |f| require(f) }"
@@ -31,6 +20,10 @@ clean:
docker stop pbx_hours_development
docker rm pbx_hours_development

run:
$(CMD_PREFIX) foreman start


##
# Set up the project for building
setup: ruby packages

+ 2
- 0
Procfile View File

@@ -0,0 +1,2 @@
web: bundle exec rake run_web
processors: bundle exec rake run_processors

+ 27
- 0
Rakefile View File

@@ -11,6 +11,33 @@ task :environment do
require 'lib/hours'
end

desc 'Setup Event Stream Processors'
task setup_processors: :environment do
HiveMap::Projections::ProposedNodes::Projector.new.setup
end

desc 'Run Event Stream Processors'
task run_processors: :environment do
# Need to disconnect before starting the processors so
# that the forked processes have their own connection / fork safety.
HiveMap.projections_database.disconnect

esps = [
HiveMap::Projections::ProposedNodes::Projector.new
]

# The ESPRunner will fork child processes for each of the ESPs passed to it.
EventSourcery::EventProcessing::ESPRunner.new(
event_processors: esps,
event_source: HiveMap.event_source,
).start!
end

desc 'Run webserver'
task run_web: :environment do
sh %(bundle exec rackup)
end

namespace :db do
desc 'Create database'
task create: [:unset_db_name, :environment] do

+ 5
- 0
config.ru View File

@@ -0,0 +1,5 @@
$LOAD_PATH << '.'

require 'lib/hive_map.rb'

run Sinatra::Application

Loading…
Cancel
Save