litestack 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.standard.yml +3 -1
  3. data/BENCHMARKS.md +3 -3
  4. data/CAVEATS.md +20 -0
  5. data/CHANGELOG.md +19 -4
  6. data/FILESYSTEMS.md +55 -0
  7. data/Gemfile +2 -0
  8. data/README.md +2 -2
  9. data/ROADMAP.md +6 -6
  10. data/assets/litestack_advantage.png +0 -0
  11. data/bench/bench.rb +2 -0
  12. data/bench/bench_cache_rails.rb +14 -17
  13. data/bench/bench_cache_raw.rb +18 -15
  14. data/bench/bench_jobs_rails.rb +3 -3
  15. data/bench/bench_jobs_raw.rb +3 -3
  16. data/bin/liteboard +16 -14
  17. data/gemfiles/rails70.gemfile +5 -0
  18. data/gemfiles/rails71.gemfile +5 -0
  19. data/gemfiles/rails71.gemfile.lock +264 -0
  20. data/lib/active_job/queue_adapters/litejob_adapter.rb +11 -3
  21. data/lib/active_record/connection_adapters/litedb_adapter.rb +17 -7
  22. data/lib/active_support/cache/litecache.rb +25 -15
  23. data/lib/generators/litestack/install/install_generator.rb +2 -2
  24. data/lib/litestack/liteboard/liteboard.rb +15 -19
  25. data/lib/litestack/liteboard/views/litecable.erb +1 -1
  26. data/lib/litestack/litecable.rb +1 -1
  27. data/lib/litestack/litecache.rb +23 -25
  28. data/lib/litestack/litedb.rb +5 -1
  29. data/lib/litestack/litejob.rb +1 -1
  30. data/lib/litestack/litejobqueue.rb +24 -14
  31. data/lib/litestack/litemetric.rb +7 -6
  32. data/lib/litestack/litequeue.rb +17 -2
  33. data/lib/litestack/litequeue.sql.yml +38 -5
  34. data/lib/litestack/litescheduler.rb +1 -2
  35. data/lib/litestack/litesearch/index.rb +11 -10
  36. data/lib/litestack/litesearch/model.rb +61 -3
  37. data/lib/litestack/litesearch/schema.rb +7 -2
  38. data/lib/litestack/litesearch/schema_adapters/backed_adapter.rb +69 -25
  39. data/lib/litestack/litesearch/schema_adapters.rb +4 -4
  40. data/lib/litestack/litesearch.rb +2 -2
  41. data/lib/litestack/litesupport.rb +7 -6
  42. data/lib/litestack/railtie.rb +4 -2
  43. data/lib/litestack/version.rb +1 -1
  44. data/lib/litestack.rb +15 -15
  45. data/lib/sequel/adapters/litedb.rb +9 -1
  46. data/lib/sequel/adapters/shared/litedb.rb +2 -2
  47. data/scripts/build_metrics.rb +2 -2
  48. data/scripts/test_cable.rb +1 -1
  49. metadata +95 -59
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2ac02213caf3525c40b676550a6daa24380f3012a5d4c8f8042cf39aa477593
4
- data.tar.gz: 00d0f60e20bcba2cc22704d4e7159fe9b819920d313e7dc7d4e4e799420e95ca
3
+ metadata.gz: ddcc1a0b4d5a5547b3e3deec7ce5abec68e31ffce348913867368513276ac69a
4
+ data.tar.gz: 743a21e710d5351131a2cbe50a94de13653a034b88d08b82e470bb3aac2bdfbb
5
5
  SHA512:
6
- metadata.gz: 7c9c726aecbfd99ad73d82c50c285178becefb4792ece0672b55dfede10a47f0563700a691398373f372ca829491c13e0332a81b9b075f9a0435ae55ac138a1c
7
- data.tar.gz: b4a28527632a3065d0deb8eadb5c806d260edfd89aa9b3f00ebbc20a2aa63ebfb7df907e7bd0a500f9e368ecd91b8967789b1f056632ef5bc73502dbbe1524c9
6
+ metadata.gz: f54bdc732995e8083791c6b214ec6058bb439548ffdcbb14f33fbbeadbca870f4941cff558cdcbfa26212e53080534c12bfacfdfa2ba8ca689f380679ef0504a
7
+ data.tar.gz: f0a1fe1c95a592e69175e55ad212e351d5bca907b43c4215a4eca919d8dc2dfda68d80fa0ceb74da5909bf822adf0b2ea45e9108fcf0cd995a0a4b337a908ad0
data/.standard.yml CHANGED
@@ -1,3 +1,5 @@
1
1
  ignore:
2
2
  - 'test/**/*':
3
- - Style/GlobalVars
3
+ - Style/GlobalVars
4
+
5
+ ruby_version: 3.0
data/BENCHMARKS.md CHANGED
@@ -125,11 +125,11 @@ On average, Litecable is quite faster than the Redis based version and offers be
125
125
 
126
126
  > ![litesearch](https://github.com/oldmoe/litestack/blob/master/assets/litesearch_logo_teal.png?raw=true)
127
127
 
128
- Litesearch was benchmarked against Mielsearch, both using their respective ActiveRecord integrations. Mielsearch was running on the same machine as the benchmark script and was using the default configuration options. The dataset used for testing was the infamous Enron email corpus. Redisearch was not benchmarked due to the clients being not Rails 7.1 compatible (yet), will probably bench Redisearch when they are.
128
+ Litesearch was benchmarked against Meilisearch, both using their respective ActiveRecord integrations. Meilisearch was running on the same machine as the benchmark script and was using the default configuration options. The dataset used for testing was the infamous Enron email corpus. Redisearch was not benchmarked due to the clients being not Rails 7.1 compatible (yet), will probably bench Redisearch when they are.
129
129
 
130
130
  ### Building the index
131
131
 
132
- ||MieliSearch|Litesearch|
132
+ ||Meilisearch|Litesearch|
133
133
  |-:|-:|-:|
134
134
  |Time to insert 10K docs|265.42 seconds|29.06 seconds|
135
135
  |Inserted docs/second|38|344|
@@ -137,4 +137,4 @@ Litesearch was benchmarked against Mielsearch, both using their respective Activ
137
137
  |Searches/second|133|19608|
138
138
  |Index rebuild|0.822|0.626|
139
139
 
140
- We only limited the test to 10K documents becuause MieliSearch was taking a long time to index, so we decided to stop at a reasonable sample size. The search numbers for litesearch were double checked, event against a 100K document set and they remained virtually the same. It is clear that litesearch is much faster than MieliSearch in both indexing and searching, this could be partially attributed to litesearch being a simpler text search engine, but still, the difference is huge! For rebuilding the index though, Litesearch is not that much faster than Mielisearch.
140
+ We only limited the test to 10K documents becuause Meilisearch was taking a long time to index, so we decided to stop at a reasonable sample size. The search numbers for litesearch were double checked, event against a 100K document set and they remained virtually the same. It is clear that litesearch is much faster than Meilisearch in both indexing and searching, this could be partially attributed to litesearch being a simpler text search engine, but still, the difference is huge! For rebuilding the index though, Litesearch is not that much faster than Meilisearch.
data/CAVEATS.md ADDED
@@ -0,0 +1,20 @@
1
+ # CAVEATS
2
+
3
+ This is a document that lists some caveats that you need to consider when dealing with Litestack and SQLite applications
4
+
5
+ ## Single host (server) only
6
+
7
+ By design, SQLite can be accessed only (in a performant and safe way) from a single host machine. That means that you cannot have things like auto-scaling of app servers since there is but a single one of them. This app server can be a huge one, with many processes, but only one app server at a time.
8
+
9
+ ## Containerization becomes a bit tricky
10
+
11
+ Container technology was originally designed for stateless applications. Based on this, one of the core aspects of containers is that they are immutable, deploying an app to container means destroying one container and creating another. With statefull applications, like database servers and similarly SQLite based applications, this will potentially mean a down time will be perceived, which in some approaches is mitigate but not perfectly (yet). Expect some quirks when dealing with SQLite and containers.
12
+
13
+ ## Single writer / multi reader
14
+
15
+ In its default configuration, Litestack allows one writer at a time to write to the database file, while simultaneously allowing any number of readers to access the database. Generally SQLite is pretty fast in writes, but you should be aware that a long running write operation will prevent any other writers from proceeding, for example creating an index on a very large table will stop other writers until the index creation is finished. There is no concurrent index creation facility in SQLite, yet.
16
+
17
+ ## Litestack does not release the GVL
18
+
19
+ This also applies to the Ruby SQLite3 gem, when it is performing a query, it will not allow any other threads in the Ruby process to resume until it returns. Care should be taken when writing low latency multi-threaded applications with Litestack, it is generally recommended to use fibers over threads in that case, since everything is serialized anyway it makes sense to avoid the ovreheads of mult-threaded environments
20
+
data/CHANGELOG.md CHANGED
@@ -1,15 +1,30 @@
1
1
  ## [Unreleased]
2
2
 
3
+ - [View Diff](https://github.com/oldmoe/litestack/compare/v0.4.4...master)
4
+
5
+ ## [0.4.4] - 2024-05-21
6
+
7
+ - [View Diff](https://github.com/oldmoe/litestack/compare/v0.4.3...v0.4.4)
8
+ - Fix a table not defined bug for Litesearch
9
+ - Add conditional mapping of external fields to Litesearch (backed index)
10
+ - As a consequence of the above, support AR polymorphic associations
11
+ - As a consequence of the above, support indexing and searching for ActionText attributes
12
+ - Remove 'hanami-router' as a dependency, rely on vanilla Rack for Liteboard
13
+ - All configuratin .yml files now support ERB rendering
14
+ - Fix adapter registration with Rails 7.2
15
+ - Ground work for more durable job persistence in case of a process crash
16
+ - Many minor fixes
17
+
3
18
  ## [0.4.3] - 2024-02-15
4
19
 
5
- - [View Diff](https://github.com/oldmoe/litestack/compare/v0.4.1...master)
20
+ - [View Diff](https://github.com/oldmoe/litestack/compare/v0.4.2...v0.4.3)
6
21
  - Add "sequel" as a development dependency
7
22
  - Diff links in CHANGELOG (thanks Weston Ganger)
8
- - Fix deamonize type in liteboard (thanks Julian Rubisch)
23
+ - Fix daemonize type in liteboard (thanks Julian Rubisch)
9
24
  - Better Litecache schema (streamlined numeric value support)
10
25
  - Support for set_multi and get_multi in Litecache (read_multi and write_multi support for Rails Cache store)
11
26
  - More tests written for Litecache and Rails Litecache store
12
- - Experimenting with removing the Rails LocalCache as it doesn't show enough improvement in perfromance to compensate for the memory overhead
27
+ - Experimenting with removing the Rails LocalCache as it doesn't show enough improvement in performance to compensate for the memory overhead
13
28
  - Switch Litecache to a FIFO eviction model vs LRU (thanks Julian Rubisch and Stephen Margheim)
14
29
 
15
30
  ## [0.4.2] - 2023-11-11
@@ -20,7 +35,7 @@
20
35
  - Fix Litesearch tests
21
36
  - Suppress chatty Litejob exit detector when there are no jobs in flight
22
37
  - Tidy up the test folder
23
- - [#41](https://github.com/oldmoe/litestack/pull/41) - Fix bug in Litecable where the `connected` event was not getting propogated
38
+ - [#41](https://github.com/oldmoe/litestack/pull/41) - Fix bug in Litecable where the `connected` event was not getting propagated
24
39
  - Add Litemetric and Liteboard info to README.doc
25
40
  - Fix the testing rake task
26
41
 
data/FILESYSTEMS.md ADDED
@@ -0,0 +1,55 @@
1
+ # Filesystems & Litestack
2
+
3
+ In the containerized world we live in, many layers of the hardware/software stacks are far abstracted that we no longer know they exist. For the filesystem enthusiasts out there this is a quick overview of how Litestack (and hence SQLite) can benefit from different filesystem
4
+
5
+ ## XFS
6
+
7
+ A very stable and trusted filesystem with excellent performance characteristics
8
+
9
+ - Fast reads / writes
10
+
11
+ ## EXT4
12
+
13
+ Another stable and performant filesystem
14
+
15
+ - Fast reads / writes
16
+
17
+ ## F2FS
18
+
19
+ Specially built for solid state storage, has an atomic write mode that is supported by SQLite
20
+
21
+ - Fast reads
22
+ - Reasonably fast durable writes in synchronous mode
23
+ - Compression (not very useful)
24
+
25
+ ## ZFS
26
+
27
+ Copy-on-write filesystem with a nifty set of features, very fast snapshotting but only for the FS as a whole, can send incremental snapshots to another host for backup. Naturally a lot more pages are written on write operations thus it is a bit slower in writes.
28
+
29
+ - Fast reads
30
+ - Slower writes
31
+ - FS Snapshotting with send/recv
32
+ - fast device cache
33
+ - Compression
34
+
35
+ ## Btrfs
36
+
37
+ Another CoW filesystem that delivers snapshotting and incremental send/recv at a much granular level.
38
+
39
+ - Fast reads
40
+ - Slower writes
41
+ - Fast copies (free backups)
42
+ - Sub volume Snapshotting with send/recv
43
+ - Compression
44
+
45
+ ## Bcachefs
46
+
47
+ A new CoW filesystem built on the foundations of the bcache module. Improving rapidly but still lacks a few of the common CoW fs features
48
+
49
+ - Fast reads
50
+ - Slower writes
51
+ - fast device cache
52
+
53
+
54
+
55
+
data/Gemfile CHANGED
@@ -4,3 +4,5 @@ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in litestack.gemspec
6
6
  gemspec
7
+
8
+ # gem "rails"
data/README.md CHANGED
@@ -59,7 +59,7 @@ litedb is a wrapper around SQLite3, offering a better default configuration that
59
59
 
60
60
  #### Direct litedb usage
61
61
 
62
- litedb can be used exactly as the SQLite3 gem, since litedb iherits from SQLite3
62
+ litedb can be used exactly as the SQLite3 gem, since litedb inherits from SQLite3
63
63
 
64
64
  ```ruby
65
65
  require 'litestack'
@@ -209,7 +209,7 @@ idx.search('kamal')
209
209
  idx.search('subject: awa')
210
210
  ```
211
211
 
212
- Litesearch integrates tightly with ActiveRecord ans Sequel, here are integration examples
212
+ Litesearch integrates tightly with ActiveRecord and Sequel, here are integration examples
213
213
 
214
214
  #### ActiveRecord
215
215
 
data/ROADMAP.md CHANGED
@@ -21,25 +21,25 @@ This is a list of functional/non-functional features that litestack targets to i
21
21
  - [ ] Automated testing matrix
22
22
  - [ ] Automated gem builds
23
23
  - [ ] Litedb improvements
24
- - [ ] ActiveRecord Sqlite3 Adapter compatibility mode
24
+ - [ ] ActiveRecord Sqlite3 Adapter compatibility mode
25
25
  - [ ] Sequel Sqlite3 Adapter compatibility mode
26
- - [ ] Extension bundling/loading
26
+ - [ ] Extension bundling/loading
27
27
  - [ ] Liteiob improvements
28
28
  - [ ] Persist jobs even during execution
29
29
  - [ ] Zombie job detection
30
- - [ ] Better process exit handling
30
+ - [ ] Better process exit handling
31
31
  - [ ] Faster job dispatch for the no delay case
32
32
  - [ ] Database maintenance scripts
33
33
  - [ ] Online backup
34
34
  - [ ] Restore
35
35
  - [ ] Litestream integration
36
- - [ ] CoW filesystems specific backup path
36
+ - [ ] CoW filesystem-specific backup path
37
37
  - [ ] Zero downtime deployment scripts
38
38
  - [ ] Rails
39
- - [ ] Genereic Rack Applications
39
+ - [ ] Generic Rack Applications
40
40
  - [ ] Litemetric improvements
41
41
  - [ ] Rails performance module
42
42
  - [ ] Ruby Memory/GC module
43
43
  - [ ] Restore generic module
44
44
  - [ ] Better HTML/CSS
45
- - [ ] Kredis replacement implementation?
45
+ - [ ] Kredis replacement implementation?
Binary file
data/bench/bench.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require "sqlite3"
2
2
 
3
+ #RubyVM::YJIT.enable
4
+
3
5
  def bench(msg, iterations = 1000)
4
6
  GC.start
5
7
  # GC.compact
@@ -1,6 +1,6 @@
1
1
  require "active_support"
2
2
  require_relative "../lib/litestack"
3
- require_relative "./bench"
3
+ require_relative "bench"
4
4
 
5
5
  cache = ActiveSupport::Cache::Litecache.new
6
6
 
@@ -12,10 +12,8 @@ redis = ActiveSupport::Cache.lookup_store(:redis_cache_store, {})
12
12
  values = []
13
13
  keys = []
14
14
  count = 1000
15
- payload_sizes = [10, 100, 1000, 10000]
16
- #payload_sizes = [100]
17
15
 
18
- payload_sizes.each do |size|
16
+ [10, 100, 1000, 10000].each do |size|
19
17
  count.times do
20
18
  keys << random_str(10)
21
19
  values << random_str(size)
@@ -34,17 +32,17 @@ payload_sizes.each do |size|
34
32
  end
35
33
 
36
34
  puts "== Multi Writes =="
37
- bench("litecache multi-writes", count/5) do |i|
38
- idx = i * 5
39
- payload = {}
40
- 5.times {|j| payload[keys[idx + j]] = values[idx + j] }
35
+ bench("litecache multi-writes", count / 5) do |i|
36
+ idx = i * 5
37
+ payload = {}
38
+ 5.times { |j| payload[keys[idx + j]] = values[idx + j] }
41
39
  cache.write_multi(payload)
42
40
  end
43
41
 
44
- bench("Redis multi-writes", count/5) do |i|
45
- idx = i * 5
46
- payload = {}
47
- 5.times {|j| payload[keys[idx + j]] = values[idx + j] }
42
+ bench("Redis multi-writes", count / 5) do |i|
43
+ idx = i * 5
44
+ payload = {}
45
+ 5.times { |j| payload[keys[idx + j]] = values[idx + j] }
48
46
  redis.write_multi(payload)
49
47
  end
50
48
 
@@ -58,21 +56,20 @@ payload_sizes.each do |size|
58
56
  end
59
57
 
60
58
  puts "== Multi Reads =="
61
- bench("litecache multi-reads", count/5) do |i|
59
+ bench("litecache multi-reads", count / 5) do |i|
62
60
  idx = i * 5
63
61
  payload = []
64
- 5.times {|j| payload << random_keys[idx+j]}
62
+ 5.times { |j| payload << random_keys[idx + j] }
65
63
  cache.read_multi(*payload)
66
64
  end
67
65
 
68
- bench("Redis multi-reads", count/5) do |i|
66
+ bench("Redis multi-reads", count / 5) do |i|
69
67
  idx = i * 5
70
68
  payload = []
71
- 5.times {|j| payload << random_keys[idx+j]}
69
+ 5.times { |j| payload << random_keys[idx + j] }
72
70
  redis.read_multi(*payload)
73
71
  end
74
72
 
75
-
76
73
  puts "=========================================================="
77
74
 
78
75
  keys = []
@@ -1,6 +1,6 @@
1
1
  require "redis"
2
2
  require "sqlite3"
3
- require_relative "./bench"
3
+ require_relative "bench"
4
4
 
5
5
  # require 'polyphony'
6
6
  require "async/scheduler"
@@ -11,7 +11,7 @@ Fiber.scheduler.run
11
11
  require_relative "../lib/litestack/litecache"
12
12
  # require 'litestack'
13
13
 
14
- cache = Litecache.new #({path: "../db/cache.db"}) # default settings
14
+ cache = Litecache.new # ({path: "../db/cache.db"}) # default settings
15
15
  redis = Redis.new # default settings
16
16
 
17
17
  values = []
@@ -40,17 +40,20 @@ count.times { keys << random_str(10) }
40
40
  end
41
41
 
42
42
  puts "== Multi Writes =="
43
- bench("litecache multi-writes", count/5) do |i|
44
- idx = i * 5
45
- payload = {}
46
- 5.times {|j| payload[keys[idx + j]] = values[idx + j] }
43
+ bench("litecache multi-writes", count / 5) do |i|
44
+ idx = i * 5
45
+ payload = {}
46
+ 5.times { |j| payload[keys[idx + j]] = values[idx + j] }
47
47
  cache.set_multi(payload)
48
- end
48
+ end
49
49
 
50
- bench("Redis multi-writes", count/5) do |i|
51
- idx = i * 5
52
- payload = []
53
- 5.times {|j| payload << keys[idx + j]; payload << values[idx + j]}
50
+ bench("Redis multi-writes", count / 5) do |i|
51
+ idx = i * 5
52
+ payload = []
53
+ 5.times { |j|
54
+ payload << keys[idx + j]
55
+ payload << values[idx + j]
56
+ }
54
57
  redis.mset(*payload)
55
58
  end
56
59
 
@@ -64,17 +67,17 @@ count.times { keys << random_str(10) }
64
67
  end
65
68
 
66
69
  puts "== Multi Reads =="
67
- bench("litecache multi-reads", count/5) do |i|
70
+ bench("litecache multi-reads", count / 5) do |i|
68
71
  idx = i * 5
69
72
  payload = []
70
- 5.times {|j| payload << random_keys[idx+j]}
73
+ 5.times { |j| payload << random_keys[idx + j] }
71
74
  cache.get_multi(*payload)
72
75
  end
73
76
 
74
- bench("Redis multi-reads", count/5) do |i|
77
+ bench("Redis multi-reads", count / 5) do |i|
75
78
  idx = i * 5
76
79
  payload = []
77
- 5.times {|j| payload << random_keys[idx+j]}
80
+ 5.times { |j| payload << random_keys[idx + j] }
78
81
  redis.mget(*payload)
79
82
  end
80
83
 
@@ -19,9 +19,9 @@ require "./rails_job"
19
19
  RailsJob.queue_adapter = :sidekiq
20
20
  t = Time.now.to_f
21
21
  puts "Make sure sidekiq is started with -c ./rails_job.rb"
22
- bench("enqueuing sidekiq jobs", count) do
23
- RailsJob.perform_later(count, t)
24
- end
22
+ #bench("enqueuing sidekiq jobs", count) do
23
+ # RailsJob.perform_later(count, t)
24
+ #end
25
25
 
26
26
  puts "Don't forget to check the sidekiq log for processing time conclusion"
27
27
 
@@ -18,9 +18,9 @@ require "./skjob"
18
18
 
19
19
  t = Process.clock_gettime(Process::CLOCK_MONOTONIC)
20
20
  puts "make sure sidekiq is started with skjob.rb as the job"
21
- bench("enqueuing sidekiq jobs", count) do |i|
22
- SidekiqJob.perform_async(count, t, delay)
23
- end
21
+ #bench("enqueuing sidekiq jobs", count) do |i|
22
+ # SidekiqJob.perform_async(count, t, delay)
23
+ #end
24
24
 
25
25
  puts "Don't forget to check the sidekiq log for processing time conclusion"
26
26
 
data/bin/liteboard CHANGED
@@ -2,20 +2,23 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'optparse'
5
+ require 'erb'
6
+ require 'yaml'
7
+ require 'rackup'
5
8
  require_relative '../lib/litestack/liteboard/liteboard'
6
9
  DEFAULTS = {
7
10
  config_path: Litemetric::DEFAULT_OPTIONS[:config_path],
8
11
  path: Litemetric::DEFAULT_OPTIONS[:path]
9
12
  }
10
13
 
11
- options = {
14
+ options = {
12
15
  config_path: nil,
13
16
  path: nil,
14
- deamonize: false,
17
+ daemonize: false,
15
18
  Port: 9292,
16
19
  Host: 'localhost',
17
20
  environment: 'production',
18
- pid: 'tmp/pids/liteboard.pid',
21
+ pid: './liteboard.pid',
19
22
  quiet: false
20
23
  }
21
24
 
@@ -26,9 +29,9 @@ OptionParser.new do |parser|
26
29
  parser.on("-s", "--server SERVER", "use SERVER (e.g. puma/falcon/iodine)") { |v| options[:port] = v }
27
30
  parser.on("-H", "--host HOST", "listen on HOST (default: #{options[:Host]})") { |v| options[:Host] = v }
28
31
  parser.on("-p", "--port PORT", "use PORT (default: #{options[:Port]})") { |v| options[:Port] = v.to_i rescue options[:Port] }
29
- parser.on("-D", "--daemonize", "run in the background") { |v| options[:daemonize] = true }
30
- parser.on("-E", "--env ENVIRONMENT", "which environment to use (default: #{options[:environment]})") { |v| options[:environment] = v }
31
- parser.on("-q", "--quiet", "turn off logging") { |v| options[:quiet] = true }
32
+ parser.on("-D", "--daemonize", "run in the background") { |v| options[:daemonize] = true }
33
+ parser.on("-E", "--env ENVIRONMENT", "which environment to use (default: #{options[:environment]})") { |v| options[:environment] = v }
34
+ parser.on("-q", "--quiet", "turn off logging") { |v| options[:quiet] = true }
32
35
  parser.on("-h", "--help", "print this message") do
33
36
  puts parser
34
37
  exit
@@ -36,40 +39,39 @@ OptionParser.new do |parser|
36
39
  end.parse!
37
40
 
38
41
  def check_database(path)
39
- unless File.exist?(path)
42
+ unless File.exist?(path)
40
43
  puts "liteboard: missing database file, please ensure the db path is correct"
41
44
  puts "liteboard: exiting"
42
45
  exit
43
46
  end
44
47
  end
45
48
 
46
- check_database(options[:path]) if options[:path]
49
+ check_database(options[:path]) if options[:path]
47
50
 
48
51
  # if there is a config file then we need to check it
49
52
  config = nil
50
53
  if options[:config_path]
51
54
  begin
52
- config = Yaml.load_file(options[:config_path])
55
+ config = YAML.load(ERB.new(File.read(options[:config_path])).result)
53
56
  rescue
54
57
  puts "liteboard: missing or bad config file, please ensure the config file path is correct"
55
58
  puts "liteboard: exiting"
56
59
  exit
57
- end
60
+ end
58
61
  else # no config path! use the default
59
- config = Yaml.load_file(DEFAULTS[:config_path]) rescue nil
62
+ config = YAML.load(ERB.new(File.read(DEFAULTS[:config_path])).result) rescue nil
60
63
  end
61
64
 
62
65
  if config
63
66
  if options[:path].nil?
64
67
  path = config['path'] || config[options[:environment]]['path']
65
68
  options[:path] = path
66
- end
69
+ end
67
70
  end
68
71
 
69
72
  # if still no path we assume a default db path
70
73
  options[:path] = DEFAULTS[:path] if options[:path].nil?
71
74
 
72
-
73
75
  # check the validity of the path before starting the server
74
76
  check_database(options[:path])
75
77
  Litemetric.options = options
@@ -79,4 +81,4 @@ options[:app] = Liteboard.app
79
81
  require_relative '../lib/litestack'
80
82
  puts "Starting Liteboard version #{Litestack::VERSION}"
81
83
 
82
- Rack::Server.start(options)
84
+ Rackup::Server.start(options)
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: "../"
4
+
5
+ gem "rails", "~> 7.0"
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: "../"
4
+
5
+ gem "rails", "~> 7.1"