Skip to content

Handle uncaught error when content directory becomes invalid #249

@sstafford

Description

@sstafford

Description
I am currently experiencing an application error that I believe to be caused when the underlying directory (--dir ) gets removed or updated to point to a new location. After the filesystem update, the next request to the server responds with an HTTP 200 response code and the following content in the body:

curl http://localhost:8085/


Fatal error: Uncaught Error: Call to a member function getUri() on null in /daux/libs/Server/Server.php:155
Stack trace:
#0 /daux/libs/Server/Server.php(66): Todaymade\Daux\Server\Server->handle()
#1 /daux/index.php(80): Todaymade\Daux\Server\Server::serve()
#2 {main}
thrown in /daux/libs/Server/Server.php on line 155

Steps to Reproduce

  1. Create a directory called "/tmp/content" containing an index.md file
  2. Start the daux docker container, mounting the /tmp/content directory under "/content" and using the "--dir /content" argument
  3. Use curl to verify that the index page is returned successfully
  4. Use the "docker exec" command to shell into the container and remove the /content/index.md file
  5. Use curl again to reproduce the error

Runtime Environment

docker run -p 8085:8085 --rm -it -v /tmp/content:/content -v /tmp/config:/config daux/daux.io daux serve --quiet --host=0.0.0.0 --port=8085 --source=/content --configuration=/config/config.json

Expected behavior

The error needs to be caught and the HTTP response needs to return a 404 or a 500 error.

Additional context

I am trying to deploy the "git-sync" container and the daux container in a kubernetes environment. The git-sync container syncs the markdown files to a volume and the daux container is responsible for serving up the content. However, when the git-sync container pulls down a new commit, it appears to create a new directory and update the symlink to the directory where daux is loading the content. The daux container then fails to load content from that point forward and needs to be restarted in order to work again. I was hoping to force the container to restart under this condition by using a Kuberntes liveness probe on the root URL, but since the daux fails to catch the unhandled error the HTTP server always returns an HTTP 200 response code and the liveness probe will always be successful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions