Skip to content

Commit

Permalink
disable litefs, backups with date (#191)
Browse files Browse the repository at this point in the history
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
fdietze and mergify[bot] authored Sep 1, 2024
1 parent 1c72bcf commit 1a8d7d3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 46 deletions.
19 changes: 10 additions & 9 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -116,25 +116,26 @@ docker-image:
COPY --dir migrate.ts migrations startup.sh index.js ./

ENV APP_DATABASE_FILENAME="sqlite.db"
ENV APP_DATABASE_PATH="$LITEFS_DIR/$APP_DATABASE_FILENAME"
ENV GB_DATABASE_PATH="$LITEFS_DIR/global-brain.db"
ENV APP_DATABASE_PATH="/data/$APP_DATABASE_FILENAME"
ENV GB_DATABASE_PATH="/data/global-brain.db"
ENV APP_DATABASE_URL="file:$APP_DATABASE_PATH"
ENV CACHE_DATABASE_FILENAME="cache.db"
ENV CACHE_DATABASE_PATH="/$LITEFS_DIR/$CACHE_DATABASE_FILENAME"
ENV CACHE_DATABASE_PATH="/data/$CACHE_DATABASE_FILENAME"
ENV HTTP_LOG_PATH="/data/http-log.jsonl"
ENV INTERNAL_PORT="8080"
ENV PORT="8081"

RUN find / \( -type f -o -type d \) -mindepth 1 -maxdepth 1 -print0 | xargs -0 du -sh | sort -hr | head -20 \
&& find /nix/store \( -type f -o -type d \) -mindepth 1 -maxdepth 1 -print0 | xargs -0 du -sh | sort -hr | head -20 \
&& find /app \( -type f -o -type d \) -mindepth 1 -maxdepth 1 -print0 | xargs -0 du -sh | sort -hr | head -20 \
&& find /app/node_modules \( -type f -o -type d \) -mindepth 1 -maxdepth 1 -print0 | xargs -0 du -sh | sort -hr | head -20 \
&& find /root \( -type f -o -type d \) -mindepth 1 -maxdepth 1 -print0 | xargs -0 du -sh | sort -hr | head -20
# RUN find / \( -type f -o -type d \) -mindepth 1 -maxdepth 1 -print0 | xargs -0 du -sh | sort -hr | head -20 \
# && find /nix/store \( -type f -o -type d \) -mindepth 1 -maxdepth 1 -print0 | xargs -0 du -sh | sort -hr | head -20 \
# && find /app \( -type f -o -type d \) -mindepth 1 -maxdepth 1 -print0 | xargs -0 du -sh | sort -hr | head -20 \
# && find /app/node_modules \( -type f -o -type d \) -mindepth 1 -maxdepth 1 -print0 | xargs -0 du -sh | sort -hr | head -20 \
# && find /root \( -type f -o -type d \) -mindepth 1 -maxdepth 1 -print0 | xargs -0 du -sh | sort -hr | head -20

# starting the application is defined in litefs.yml
# test locally without litefs:
# docker run -e SESSION_SECRET -e INTERNAL_COMMAND_TOKEN -e HONEYPOT_SECRET sha256:xyzxyz /bin/sh startup.sh
CMD ["/usr/local/bin/litefs", "mount"]
# CMD ["/usr/local/bin/litefs", "mount"]
CMD ["/app/startup.sh"]
SAVE IMAGE jabble:latest

docker-image-e2e-test:
Expand Down
42 changes: 7 additions & 35 deletions fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,45 +20,17 @@ destination = "/data"
[deploy]
release_command = "node ./other/sentry-create-release"

[[services]]
internal_port = 8_080
processes = ["app"]
protocol = "tcp"
script_checks = []

# [services.concurrency]
# hard_limit = 100
# soft_limit = 80
# type = "requests"

[[services.ports]]
handlers = ["http"]
port = 80
[http_service]
internal_port = 8081
force_https = true
# auto_stop_machines = "stop" # action when the app is idle for several minutes
# auto_start_machines = true
min_machines_running = 0

[[services.ports]]
handlers = ["tls", "http"]
port = 443

[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"

[[services.http_checks]]
interval = "10s"
grace_period = "5s"
method = "get"
path = "/resources/healthcheck"
protocol = "http"
timeout = "2s"
tls_skip_verify = false
headers = {}

[[services.http_checks]]
[[http_service.checks]]
grace_period = "10s"
interval = "30s"
method = "GET"
timeout = "5s"
path = "/litefs/health"
path = "/resources/healthcheck"
4 changes: 2 additions & 2 deletions startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
set -Eeuo pipefail

echo create a backup before migrating...
sqlite3 /litefs/data/sqlite.db '.backup /data/backup.db'
ls -lh /data/backup.db
sqlite3 /litefs/data/sqlite.db ".backup /data/backup-$(date -Iseconds).db"
ls -lh /data/backup*

npm run migrate

Expand Down

0 comments on commit 1a8d7d3

Please sign in to comment.