LiteFS complaining about readonly on laravel on non-primary machines

Heya! So far LiteFS is kicking my butt. I have made a ton of progress on my own searching this forum but I think I need to ask for some help.

In short, I believe I have LiteFS setup properly, but given that Laravel uses it for caching and session and other things. It works wonderfully in my primary region and the primary! But in any other region or machine that is not my primary I am getting the following error:

	
{"message":"SQLSTATE[HY000]: General error: 8 attempt to write a readonly database (Connection: sqlite, SQL: insert or ignore into \"cache\" (\"key\", \"value\", \"expiration\") values (laravel_cache_705c48c0e1497ceab8b9fbf0b6eb6a70:timer, i:1735687817;, 1735687817))","context":{"exception":{"class":"Illuminate\\Database\\QueryException","message":"SQLSTATE[HY000]: General error: 8 attempt to write a readonly database (Connection: sqlite, SQL: insert or ignore into \"cache\" (\"key\", \"value\", \"expiration\") values (laravel_cache_705c48c0e1497ceab8b9fbf0b6eb6a70:timer, i:1735687817;, 1735687817))","code":0,"file":"/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:825","previous":{"class":"PDOException","message":"SQLSTATE[HY000]: General error: 8 attempt to write a readonly database","code":0,"file":"/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:596"}}},"level":400,"level_name":"ERROR","channel":"production","datetime":"2024-12-31T23:29:17.817156

For reference, here is my fly.toml:

# fly.toml app configuration file generated for laravel-bluefin on 2024-12-01T21:44:48-06:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'laravel-bluefin'
primary_region = 'dfw'
console_command = 'php /var/www/html/artisan tinker'

[build]
  [build.args]
    NODE_VERSION = '18'
    PHP_VERSION = '8.3'

[deploy]
  strategy = "rolling"
  max_unavailable = 1



[env]
  APP_ENV = 'production'
  LOG_CHANNEL = 'stderr'
  LOG_LEVEL = 'info'
  LOG_STDERR_FORMATTER = 'Monolog\Formatter\JsonFormatter'
  SESSION_DRIVER = 'cookie'
  SESSION_SECURE_COOKIE = 'true'
  CACHE_DRIVER='file'
  DB_CONNECTION='sqlite'
  DB_DATABASE='/var/www/html/storage/database/app/database.sqlite'


[[mounts]]
  source = 'litefs'
  destination = '/var/www/html/storage/'

[http_service]
  internal_port = 8080
  force_https = true
  auto_stop_machines = 'stop'
  auto_start_machines = true
  min_machines_running = 1
  processes = ['app']


[[http_service.checks]]
  interval = "2s"
  grace_period = "5s"
  method = "GET"
  path = "/up"
  protocol = "http"
  port = 8080
  timeout = "2s"
  tls_skip_verify = false

[[vm]]
  memory = '256mb'
  cpu_kind = 'shared'
  cpus = 1

The relevant bits of my litefs.yml are:

fuse:
  dir: "/var/www/html/storage/database/app"
  allow-other: true
  debug: false
data:
  dir: "/var/www/html/storage/database/litefs"

and I have copy-pasted the FlyReplayLiteFSWrite.php from the github. I believe I am missing something that is no longer in the github that is refrenced in the Beta documentation #8, the allow fly replay to work with the CSRF protection? Is that still required? Or is my app still just trying to cache on the database where it shouldn’t? Ideally things like caches and sessions should be held on the machine itself for quickest load times.

Would it be possible to have a different database location for persistent stuff and do small things like caching and sessions in a rootfs database that can be blown away on rebuild?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.