dhilt / dharmadict

MIT License
1 stars 2 forks source link

Dharma Dictionary

Prerequisites

Production Server via Docker

Docker setup encapsulates all necessary server side infrastructure, including Elasticsearch DB setup & migrations. The following commands provide all-included setup:

Commands should be run in the project root folder. And this folder should be a Docker shared resource. Also, Elasticsearch DB requires > 2Gb RAM, a Docker memory limit setting should satisfy this requirement (4Gb seem to be enough).

If this is done without errors, the result should be available on http://localhost:3000/.

Production Server "as is"

As an alternative, the production server can be installed and run "as is", without Docker. This is the way the production server runs in the remote environment. And this can be used for the server application development. The following instructions should be accomplished once:

Now the server can work locally:

Client App Development

The following should be accomplished once:

Production server must be accessible on 3000 port. If it works, the client application can be run via

If the production server is expected to be run "as is" (without Docker), the following command allows to join both processes in a single one:

After the development is done, the production version of the client app should be built via npm run build.


Database Setup

Java

OR

Elasticsearch

Configuration

Need to set some options

script.inline: on
script.engine.groovy.inline.aggs: on
path.repo: ["/path_to_backups"]

Run

Making a snapshot (export data)

Following https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html

  1. Register a snapshot repository
curl -XPUT 'http://localhost:9200/_snapshot/my_backup' -H 'Content-Type: application/json' -d'
{
    "type": "fs",
    "settings": {
        "location": "my_backup",
        "compress": true
    }
}'

Then "my_backup" folder should appear in "/path_to_backups" folder (/path_to_backups/my_backup). If not (permission issue?), create it manually.

  1. Check if the repository has been created properly
curl -XGET 'http://localhost:9200/_snapshot/my_backup'
  1. Make a snapshot of "dharmadict" index
curl -XPUT 'http://localhost:9200/_snapshot/my_backup/snap1' {
    "indices": "dharmadict",
    "ignore_unavailable": true,
    "include_global_state": false
}

This will create "/path_to_backups/my_backup/snap1" folder and fill it up with elastic snapshot data.

  1. Check if the snapshot has been created properly
curl -XGET 'http://localhost:9200/_snapshot/my_backup/snap1'

Restoring the snapshot (import data)

  1. Before restore we need to block "dharmadict" index
curl -XPOST 'localhost:9200/dharmadict/_close?pretty'
  1. Now, a snapshot can be restored using the following command:
curl -XPOST 'localhost:9200/_snapshot/my_backup/snap1/_restore?pretty' -H 'Content-Type: application/json' -d'
{
  "indices": "dharmadict",
  "ignore_unavailable": true
}