chibisafe / chibisafe

Blazing fast file vault written in TypeScript! 🚀
https://chibisafe.app
MIT License
1.64k stars 266 forks source link

[BUG] All links result in 404 when Serve Uploads From is filled with a valid domain #460

Closed bielej closed 10 months ago

bielej commented 11 months ago

Describe the bug I have noticed that I have 4 zombie processes. After checking ps it was clear that these processes are from Chibisafe Docker container. I have decided to restart the container using docker stop chibisafe and docker start chibisafe. Later that day I have discovered that all file URLs from Chibisafe won't work anymore.

{"message":"Route GET:/L64W0bmCWIKV.png not found","error":"Not Found","statusCode":404}

but:

$ docker exec -it chibisafe sh
/home/node/chibisafe # find . -name '*L64W0bmCWIKV*'
./uploads/thumbs/L64W0bmCWIKV.webp
./uploads/thumbs/square/L64W0bmCWIKV.webp
./uploads/L64W0bmCWIKV.png

Uploading images works fine, but the newly uploaded image still does not have a thumbnail and the permalink returns a 404.

To Reproduce Steps to reproduce the behavior:

  1. Restart the container
  2. See that all thumbnails in the dashboard are gone and none of the links work.

Expected behavior I would like to be able to restart the container without unforeseen consequences.

Screenshots image

Additional context Latest, manual build from master.

docker-compose.yml


services:
  chibisafe:
    image: chibisafe/chibisafe:latest
    container_name: chibisafe
    build:
      context: ./
      dockerfile: ./Dockerfile
    volumes:
      - /var/docker_volumes/chibisafe/database:/home/node/chibisafe/database
      - /var/docker_volumes/chibisafe/uploads:/home/node/chibisafe/uploads
      - /var/docker_volumes/chibisafe/logs:/home/node/chibisafe/logs
    ports:
      - 24424:8000
    restart: unless-stopped

Startup log:

[+] Running 1/0
 ⠿ Container chibisafe  Created                                                                                                                                                              0.0s
Attaching to chibisafe
chibisafe  | Prisma schema loaded from src/prisma/schema.prisma
chibisafe  | Datasource "db": SQLite database "database.sqlite" at "file:../../../../database/database.sqlite"
chibisafe  |
chibisafe  | 4 migrations found in prisma/migrations
chibisafe  |
chibisafe  |
chibisafe  | No pending migrations to apply.
chibisafe  | Prisma schema loaded from src/prisma/schema.prisma
chibisafe  |
chibisafe  | ✔ Generated Prisma Client (4.15.0 | library) to ./../../node_modules/@prisma/client in 271ms
chibisafe  | You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
chibisafe  | ```
chibisafe  | import { PrismaClient } from '@prisma/client'
chibisafe  | const prisma = new PrismaClient()
chibisafe  | ```
chibisafe  | Prisma schema loaded from src/prisma/schema.prisma
chibisafe  | Datasource "db": SQLite database "database.sqlite" at "file:../../../../database/database.sqlite"
chibisafe  |
chibisafe  | 4 migrations found in prisma/migrations
chibisafe  |
chibisafe  |
chibisafe  | No pending migrations to apply.
chibisafe  | Prisma schema loaded from src/prisma/schema.prisma
chibisafe  |
chibisafe  | ✔ Generated Prisma Client (4.15.0 | library) to ./../../node_modules/@prisma/client in 217ms
chibisafe  | You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
chibisafe  | ```
chibisafe  | import { PrismaClient } from '@prisma/client'
chibisafe  | const prisma = new PrismaClient()
chibisafe  | ```
chibisafe  | Chibisafe is listening on 0.0.0.0:8000

All files are there (with proper owner/group/chmod), the database is there:

sqlite> select count(*) from files;
215
bielej commented 11 months ago

I've figured it out. It's Serve Uploads From fault. When filled with a valid domain name (in my case img.example.com) it breaks all the links. Leaving it blank solves the issue. Still, it looks like a bug to me.

pilar6195 commented 11 months ago

Yeah, this is intended. If the Serve Uploads From option is set then chibisafe will no longer serve the files and it would be up to you to serve them via other means (nginx, caddy, apache, etc.) on the domain you specify.

This should probably be made clearer.

Pitu commented 10 months ago

We just updated the wording for the setting in hopes it's not confusing any more https://github.com/chibisafe/chibisafe/commit/385a1cf30b5f67d808877352fb66a5d03a211968

As for the zombie processes, I'm not sure where to even begin checking what could be the issue if it actually is one. No unusual memory usage or cpu from those processes I assume?

bielej commented 10 months ago

Thanks for changing the wording, now it's clear.

USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root       10011  0.0  0.0      0     0 ?        Zs   Aug11   0:00      \_ [node] <defunct>
root       10188  0.0  0.0      0     0 ?        Zs   Aug11   0:00      \_ [node] <defunct>
root       10267  0.0  0.0      0     0 ?        Zs   Aug11   0:00      \_ [node] <defunct>

Yup, zero resources usage.

Pitu commented 10 months ago

Thank you for reporting this, we'll keep an eye on it and check if it becomes a problem or at the very least determine why it happens.