litestream 0.3.1-x86_64-linux → 0.3.3-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e0dfceb2a82029901fbe794fc1289e3e85215027cb64d5c8a7c97a35ec19efe4
4
- data.tar.gz: 69273d9b39b6278870c50e4dee01be6eebc471b7bcb7cebcd578ab02af231131
3
+ metadata.gz: a811fa93e4a3db5f8ef90904fea642ccb0ea146ace97bf141b716fe6b18e6ce6
4
+ data.tar.gz: 6b0cae674c1d28cbcefae49793e39df01da662ebcc567458852b819ef87e651b
5
5
  SHA512:
6
- metadata.gz: 7ad077a654dd162491a0a8f24725e26a7922c0fae2da3d518d497b58cd688204af1d1c88f2a33f5be2e79329cb419437af71a672e085e32b4bca634705cbdc53
7
- data.tar.gz: a7c6d3aa1fe400f603d67e17e92d92b54ca81eb2aab37625dcc55757e950aac6b1fa882c0b81cc473b6ddf79798cfc0c3a02cf8a209b2fc0099905012f6595ea
6
+ metadata.gz: 801f7a80f55c91119c41f685b52cf86ca70aa01e74396b85b56fd399e1626a423aa0bee0bea2146813810d7759c72720849ce9fc967b24bea66b8ff2024bf72c
7
+ data.tar.gz: 5da3badade7b5ab0c282ae208d26aa1ff62e30e29c930bedcf5542747edd7b989fcf0f1252a84c453fef502a685a6e850fb380fe189ba7f99067e7145924351d
data/README.md CHANGED
@@ -76,9 +76,23 @@ However, if you need manual control over the Litestream configuration, you can m
76
76
 
77
77
  ### Replication
78
78
 
79
- By default, the gem will create or append to a `Procfile` to start the Litestream process via the gem's provided `litestream:replicate` rake task. This rake task will automatically load the configuration file and set the environment variables before starting the Litestream process.
79
+ By default, the gem will create or append to a `Procfile` to start the Litestream process via the gem's provided `litestream:replicate` rake task. This rake task will automatically load the configuration file and set the environment variables before starting the Litestream process. You can also execute this rake task yourself:
80
80
 
81
- Again, however, you can take full manual control over the replication process and simply run the `litestream replicate --config config/litestream.yml` command to start the Litestream process. Since the gem installs the native executable via Bundler, the `litestream` command will be available in your `PATH`.
81
+ ```shell
82
+ bin/rails litestream:replicate
83
+ # or
84
+ bundle exec rake litestream:replicate
85
+ ```
86
+
87
+ If you need to pass arguments through the rake task to the underlying `litestream` command, that can be done with argument forwarding:
88
+
89
+ ```shell
90
+ bin/rails litestream:replicate -- -exec "foreman start"
91
+ ```
92
+
93
+ This example utilizes the `-exec` option available on [the `replicate` command](https://litestream.io/reference/replicate/) which provides basic process management, since Litestream will exit when the child process exits. In this example, we only launch our collection of Rails application processes (like Rails and SolidQueue, for example) after the Litestream replication process is ready.
94
+
95
+ The rake task is the recommended way to interact with the Litestream replication process in your Rails application or Ruby project. But, you _can_ take full manual control over the replication process and simply run the `litestream replicate --config config/litestream.yml` command to start the Litestream process. Since the gem installs the native executable via Bundler, the `litestream` command will be available in your `PATH`.
82
96
 
83
97
  The full set of commands available to the `litestream` executable are covered in Litestream's [command reference](https://litestream.io/reference/). Currently, only the `replicate` command is provided as a rake task by the gem.
84
98
 
@@ -72,7 +72,7 @@ module Litestream
72
72
  exe_file
73
73
  end
74
74
 
75
- def self.replicate
75
+ def self.replicate(argv = {})
76
76
  if Litestream.configuration
77
77
  ENV["LITESTREAM_DATABASE_PATH"] = Litestream.configuration.database_path
78
78
  ENV["LITESTREAM_REPLICA_URL"] = Litestream.configuration.replica_url
@@ -80,7 +80,18 @@ module Litestream
80
80
  ENV["LITESTREAM_SECRET_ACCESS_KEY"] = Litestream.configuration.replica_access_key
81
81
  end
82
82
 
83
- system(executable, "replicate", "--config", Rails.root.join("config", "litestream.yml").to_s)
83
+ args = {
84
+ "--config" => Rails.root.join("config", "litestream.yml").to_s
85
+ }.merge(argv).to_a.flatten.compact
86
+
87
+ command = [executable, "replicate", *args]
88
+ puts command.inspect
89
+
90
+ # To release the resources of the Ruby process, just fork and exit.
91
+ # The forked process executes litestream and replaces itself.
92
+ if fork.nil?
93
+ exec(*command)
94
+ end
84
95
  end
85
96
  end
86
97
  end
@@ -8,11 +8,11 @@ module Litestream
8
8
  source_root File.expand_path("templates", __dir__)
9
9
 
10
10
  def copy_config_file
11
- template "litestream.yml", "config/litestream.yml"
11
+ template "config.yml", "config/litestream.yml"
12
12
  end
13
13
 
14
14
  def copy_initializer_file
15
- template "litestream.rb", "config/initializers/litestream.rb"
15
+ template "initializer.rb", "config/initializers/litestream.rb"
16
16
  end
17
17
 
18
18
  def create_or_update_procfile
@@ -9,7 +9,7 @@ module Litestream
9
9
  require_relative "generators/litestream/install_generator"
10
10
  end
11
11
 
12
- # Load the `litestream:env` Rake task into the host Rails app
12
+ # Load the `litestream:*` Rake task into the host Rails app
13
13
  rake_tasks do
14
14
  load "tasks/litestream_tasks.rake"
15
15
  end
@@ -1,3 +1,3 @@
1
1
  module Litestream
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.3"
3
3
  end
@@ -14,8 +14,15 @@ namespace :litestream do
14
14
  true
15
15
  end
16
16
 
17
- desc ""
17
+ desc "Start a process to monitor and continuously replicate the SQLite databases defined in your configuration file"
18
18
  task replicate: :environment do
19
- Litestream::Commands.replicate
19
+ options = {}
20
+ if (separator_index = ARGV.index("--"))
21
+ ARGV.slice(separator_index + 1, ARGV.length)
22
+ .map { |pair| pair.split("=") }
23
+ .each { |opt| options[opt[0]] = opt[1] || nil }
24
+ end
25
+
26
+ Litestream::Commands.replicate(options)
20
27
  end
21
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: litestream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Stephen Margheim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-21 00:00:00.000000000 Z
11
+ date: 2024-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -69,8 +69,8 @@ files:
69
69
  - lib/litestream.rb
70
70
  - lib/litestream/commands.rb
71
71
  - lib/litestream/generators/litestream/install_generator.rb
72
- - lib/litestream/generators/litestream/templates/litestream.rb
73
- - lib/litestream/generators/litestream/templates/litestream.yml
72
+ - lib/litestream/generators/litestream/templates/config.yml
73
+ - lib/litestream/generators/litestream/templates/initializer.rb
74
74
  - lib/litestream/railtie.rb
75
75
  - lib/litestream/upstream.rb
76
76
  - lib/litestream/version.rb