Algorithmic-Personalization / server

The Unlicense
1 stars 1 forks source link

Pre-Requisites

This assumes you have docker and docker-compose installed.

Configuration

Create an apache user to protect the status page:

sudo htpasswd -c /etc/apache2/.htpasswd <username>

or on EC2 probably:

sudo htpasswd -c /etc/httpd/.htpasswd <username>

Installation

Install the dependencies with:

yarn

Testing

First start the test database with:

docker-compose up -d test-db

Then run the tests once with:

yarn test

Or continuously with:

yarn tdd

Development

Starts the docker database:

Start the docker server:

Populate the local database from the remote one:

Production things

Enable backups

The following script can also be useful to save the backup to a remote server via scp:

#!/bin/env bash
host=some_host
latest_dump_path=$(find "$HOME"/ytdpnl/ytdpnl*.tar -maxdepth 0 -printf "%T@ %p\n" | sort -n | tail -n1 | cut -d' ' -f2)
name=$(basename "$latest_dump_path")
echo "Latest backup found is:"
res=$(find "$latest_dump_path" -printf '%s %AY-%Am-%Ad %AH:%AM %p\n' | numfmt --field=1 --to=iec-i)
echo " -> $res"
target="$host":"~/backups/$name"
echo "Uploading to $target..."
scp "$latest_dump_path" "$target" || exit 1
echo " -> Upload done."

Build / start the server

Stop all containers if running:

docker-compose down

Pull the code:

git pull

If the server is not very big on ram and disk, prune the docker cache:

docker system prune

Build the server code:

docker-compose build

Start the server in the background:

docker-compose up -d app-server

Or preferably in tmux:

docker-compose up app-server