Skip to content

Commit 9cf0e5b

Browse files
Merge pull request #49 from oandalib/update-readme
docs: update README
2 parents c372c7c + a4de036 commit 9cf0e5b

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

README.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ dbs:
9292
secret-access-key: $LITESTREAM_SECRET_ACCESS_KEY
9393
```
9494
95+
This is the default for Amazon S3. The full range of possible replica types (e.g. other S3-compatible object storage servers) are covered in Litestream's [replica guides](https://litestream.io/guides/#replica-guides).
96+
9597
The gem also provides a default initializer file at `config/initializers/litestream.rb` that allows you to configure these four environment variables referenced in the configuration file in Ruby. By providing a Ruby interface to these environment variables, you can use any method of storing secrets that you prefer. For example, the default generated file uses Rails' encrypted credentials to store your secrets:
9698

9799
```ruby
@@ -110,14 +112,13 @@ However, if you need manual control over the Litestream configuration, you can m
110112

111113
In order to stream changes to your configured replicas, you need to start the Litestream replication process.
112114

113-
The simplest way to run the Litestream replication process is use the Puma plugin provided by the gem. This allows you to run the Litestream replication process together with Puma and have Puma monitor and manage it. You just need to add
115+
The simplest way to run the Litestream replication process is use the Puma plugin provided by the gem. This allows you to run the Litestream replication process together with Puma and have Puma monitor and manage it. You just need to add the following to your `puma.rb` configuration:
114116

115117
```ruby
116-
plugin :litestream
118+
# Run litestream only in production.
119+
plugin :litestream if ENV.fetch("RAILS_ENV", "production") == "production"
117120
```
118121

119-
to your `puma.rb` configuration.
120-
121122
If you would prefer to run the Litestream replication process separately from Puma, you can use the provided `litestream:replicate` rake task. This rake task will automatically load the configuration file and set the environment variables before starting the Litestream process.
122123

123124
The simplest way to spin up a Litestream process separately from your Rails application is to use a `Procfile`:
@@ -220,7 +221,7 @@ You can verify the integrity of your backed-up databases using the gem's provide
220221
Litestream.verify! "storage/production.sqlite3"
221222
```
222223

223-
In order to verify that the backup for that database is both restorable and fresh, the method will add a new row to that database under the `_litestream_verification` table, which it will create if needed. It will then wait 10 seconds to give the Litestream utility time to replicate that change to whatever storage providers you have configured. After that, it will download the latest backup from that storage provider and ensure that this verification row is present in the backup. If the verification row is _not_ present, the method will raise a `Litestream::VerificationFailure` exception. This check ensures that the restored database file
224+
In order to verify that the backup for that database is both restorable and fresh, the method will add a new row to that database under the `_litestream_verification` table, which it will create if needed. It will then wait 10 seconds to give the Litestream utility time to replicate that change to whatever storage providers you have configured. After that, it will download the latest backup from that storage provider and ensure that this verification row is present in the backup. If the verification row is _not_ present, the method will raise a `Litestream::VerificationFailure` exception. This check ensures that the restored database file:
224225

225226
1. exists,
226227
2. can be opened by SQLite, and
@@ -256,8 +257,8 @@ Second, you can configure the access credentials via the Rails configuration obj
256257

257258
```ruby
258259
# Set authentication credentials for Litestream
259-
config.litestream.username = Rails.application.credentials.litestream.username
260-
config.litestream.password = Rails.application.credentials.litestream.password
260+
config.litestream.username = Rails.application.credentials.dig(:litestream, :username)
261+
config.litestream.password = Rails.application.credentials.dig(:litestream, :password)
261262
```
262263

263264
Either way, if you have set a username and password, Litestream will use basic HTTP authentication.
@@ -294,7 +295,7 @@ config.middleware.use ActionDispatch::Flash
294295

295296
### Overwriting the views
296297

297-
You can find the views in [`app/views`](https://github.com/fractaledmind/litestream/tree/main/app/views).
298+
You can find the views in [`app/views`](https://github.com/fractaledmind/litestream-ruby/tree/main/app/views).
298299

299300
```bash
300301
app/views/
@@ -362,7 +363,7 @@ You can also list the generations of a specific database:
362363
bin/rails litestream:generations -- --database=storage/production.sqlite3
363364
```
364365

365-
This will list all generations for the specified database, including stats about their lag behind the primary database and the time range they cover.
366+
This will list all generations for the specified database, including stats about their lag behind the primary database and the time range they cover:
366367

367368
```
368369
name generation lag start end
@@ -461,7 +462,13 @@ litestream wal [arguments] DB_PATH|REPLICA_URL
461462

462463
### Using in development
463464

464-
By default, installing the gem does not update your `Procfile.dev` file, and so Litestream will not be started in development. If you would like to test that your configuration is properly setup, you can manually add the `litestream:replicate` rake task to your `Procfile.dev` file. Just copy the `litestream` definition from the production `Procfile`. Then, in order to have a replication bucket for Litestream to point to, you can use a Docker instance of [MinIO](https://min.io/). MinIO is an S3-compatible object storage server that can be run locally. You can run a MinIO server with the following command:
465+
By default, if you install the gem and configure via `puma.rb` or `Procfile`, Litestream will not start in development.
466+
467+
If you setup via `puma.rb`, then remove the conditional statement.
468+
469+
If you setup via `Procfile`, you will need to update your `Procfile.dev` file. If you would like to test that your configuration is properly setup, you can manually add the `litestream:replicate` rake task to your `Procfile.dev` file. Just copy the `litestream` definition from the production `Procfile`.
470+
471+
In order to have a replication bucket for Litestream to point to, you can use a Docker instance of [MinIO](https://min.io/). MinIO is an S3-compatible object storage server that can be run locally. You can run a MinIO server with the following command:
465472

466473
```sh
467474
docker run -p 9000:9000 -p 9001:9001 minio/minio server /data --console-address ":9001"

app/views/layouts/litestream/application.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<footer class="container mx-auto mt-24 flex items-center justify-between border-t px-2 py-4 text-base">
1616
<p>
1717
<code><strong>Litestream</strong></code>&nbsp;&nbsp;|&nbsp;
18-
Made by <a href="https://twitter.com/fractaledmind" class="text-blue-500 hover:underline decoration-blue-500">@fractaledmind</a> and <a href="https://github.com/fractaledmind/litestream/graphs/contributors" class="text-blue-500 hover:underline decoration-blue-500">friends</a>! Want to help? It's <a href="https://github.com/fractaledmind/litestream" class="text-blue-500 hover:underline decoration-blue-500">open source</a>!
18+
Made by <a href="https://twitter.com/fractaledmind" class="text-blue-500 hover:underline decoration-blue-500">@fractaledmind</a> and <a href="https://github.com/fractaledmind/litestream-ruby/graphs/contributors" class="text-blue-500 hover:underline decoration-blue-500">friends</a>! Want to help? It's <a href="https://github.com/fractaledmind/litestream-ruby" class="text-blue-500 hover:underline decoration-blue-500">open source</a>!
1919
</p>
2020
</footer>
2121

0 commit comments

Comments
 (0)