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.
feature/immekaart-rebase
Bèr Kessels 1 year 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
27 27
 
28 28
   gem 'awesome_print'
29 29
   gem 'better_errors'
30
+
31
+  gem 'foreman'
30 32
 end

+ 4
- 0
Gemfile.lock View File

@@ -26,6 +26,8 @@ GEM
26 26
       sequel (>= 4.38)
27 27
     faraday (0.15.4)
28 28
       multipart-post (>= 1.2, < 3)
29
+    foreman (0.85.0)
30
+      thor (~> 0.19.1)
29 31
     jaro_winkler (1.5.2)
30 32
     json (2.1.0)
31 33
     minitest (5.11.3)
@@ -62,6 +64,7 @@ GEM
62 64
       rack (~> 2.0)
63 65
       rack-protection (= 2.0.5)
64 66
       tilt (~> 2.0)
67
+    thor (0.19.4)
65 68
     tilt (2.0.9)
66 69
     unicode-display_width (1.4.1)
67 70
 
@@ -75,6 +78,7 @@ DEPENDENCIES
75 78
   dotenv (~> 2.6)
76 79
   event_sourcery
77 80
   event_sourcery-postgres
81
+  foreman
78 82
   minitest
79 83
   nominatim!
80 84
   opening_hours_converter

+ 5
- 12
Makefile View File

@@ -1,26 +1,15 @@
1
-OUT_DIR=tmp
2 1
 CMD_PREFIX=bundle exec
3
-VERSION=$(shell semver)
4
-TODAY=$(shell date +%F)
5 2
 include .env
6 3
 
7 4
 # You want latexmk to *always* run, because make does not have all the info.
8 5
 # Also, include non-file targets in .PHONY so they are run regardless of any
9 6
 # file of the given name existing.
10
-.PHONY: all test lint clean setup ruby packages preprocess install migrate
7
+.PHONY: all test lint clean setup ruby packages preprocess run
11 8
 
12 9
 # The first rule in a Makefile is the one executed by default ("make"). It
13 10
 # should always be the "all" rule, so that "make" and "make all" are identical.
14 11
 all: test lint
15 12
 
16
-install:
17
-	docker run --name pbx_$(DB_NAME) -e POSTGRES_PASS=$(DB_PASSWORD) -e POSTGRES_USER=$(DB_USER) -p5432:$(DB_PORT) -d -t kartoza/postgis
18
-
19
-database:
20
-	$(CMD_PREFIX) rake db:drop
21
-	$(CMD_PREFIX) rake db:create
22
-	$(CMD_PREFIX) rake db:migrate
23
-
24 13
 # CUSTOM BUILD RULES
25 14
 test:
26 15
 	$(CMD_PREFIX) ruby -I lib:test:. -e "Dir.glob('**/*_test.rb') { |f| require(f) }"
@@ -31,6 +20,10 @@ clean:
31 20
 	docker stop pbx_hours_development
32 21
 	docker rm pbx_hours_development
33 22
 
23
+run:
24
+	$(CMD_PREFIX) foreman start
25
+
26
+
34 27
 ##
35 28
 # Set up the project for building
36 29
 setup: ruby packages

+ 2
- 0
Procfile View File

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

+ 27
- 0
Rakefile View File

@@ -11,6 +11,33 @@ task :environment do
11 11
   require 'lib/hours'
12 12
 end
13 13
 
14
+desc 'Setup Event Stream Processors'
15
+task setup_processors: :environment do
16
+  HiveMap::Projections::ProposedNodes::Projector.new.setup
17
+end
18
+
19
+desc 'Run Event Stream Processors'
20
+task run_processors: :environment do
21
+  # Need to disconnect before starting the processors so
22
+  # that the forked processes have their own connection / fork safety.
23
+  HiveMap.projections_database.disconnect
24
+
25
+  esps = [
26
+    HiveMap::Projections::ProposedNodes::Projector.new
27
+  ]
28
+
29
+  # The ESPRunner will fork child processes for each of the ESPs passed to it.
30
+  EventSourcery::EventProcessing::ESPRunner.new(
31
+    event_processors: esps,
32
+    event_source: HiveMap.event_source,
33
+  ).start!
34
+end
35
+
36
+desc 'Run webserver'
37
+task run_web: :environment do
38
+  sh %(bundle exec rackup)
39
+end
40
+
14 41
 namespace :db do
15 42
   desc 'Create database'
16 43
   task create: [:unset_db_name, :environment] do

+ 5
- 0
config.ru View File

@@ -0,0 +1,5 @@
1
+$LOAD_PATH << '.'
2
+
3
+require 'lib/hive_map.rb'
4
+
5
+run Sinatra::Application

Loading…
Cancel
Save