Skip to content

Recognize changes in files.source at runtime #41

@voigt

Description

@voigt

I noticed that spin-fileserver currently does not recognize file changes at runtime.

Scenario to Reproduce:

  1. Create following spin.toml
cat <<EOF > spin.toml
spin_manifest_version = "1"
authors = ["Christoph Voigt <[email protected]>"]
description = "This Spin application serves static files"
name = "static-server"
trigger = { type = "http", base = "/" }
version = "0.1.0"

[[component]]
source = { url = "https://github.com/fermyon/spin-fileserver/releases/download/v0.0.3/spin_static_fs.wasm", digest = "sha256:38bf971900228222f7f6b2ccee5051f399adca58d71692cdfdea98997965fd0d" }
id = "static-server"
files = [{ source = "content", destination = "/" }]
[component.trigger]
route = "/..."
EOF
  1. Create directory & file to be served:
$ mkdir -p content
$ cat <<EOF > content/index.html
<html>
<head>
    <title>Spin Website</title>
    <body>
        <h1>Welcome from Spin!</h1>
    </body>
</html>
EOF
  1. Serve files & request:
$ spin up
$ curl http://127.0.0.1:3000
<html>
<head>
<title>Hello from Spin</title>
</head>
<body>
<h1>Hello from Spin!</h1>
</body>
</html>
  1. Update index.html
$ cat <<EOF > content/index.html
<html>
<head>
    <title>Spin Website</title>
    <body>
        <h1>Welcome from Spin! - UPDATED</h1>
    </body>
</html>
EOF
  1. Request with the result, that the update is not served.
$ curl http://127.0.0.1:3000
<html>
<head>
<title>Hello from Spin</title>
</head>
<body>
<h1>Hello from Spin!</h1>
</body>
</html>

Expected behavior:

$ curl http://127.0.0.1:3000
<html>
<head>
    <title>Spin Website</title>
    <body>
        <h1>Welcome from Spin! - UPDATED</h1>
    </body>
</html>

Of course, I could restart Spin - but I don't think this is a desired workaround.

In a specific use case, I wanted to host Spin in Kubernetes and provide content via a sidecar container. This pattern is currently not possible.

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