App Configuration

App Configuration (app.yaml)

Wasmer Edge's configuration is stored in a app.yaml file in the root of your project.

Example

app.yaml
# Required fields
 
kind: wasmer.io/App.v0
# username or namespace that owns the app
owner: my-account
# App name
name: my-sample-site
# Package to run (it can also be `.`)
package: wasmer/my-sample-site
 
# OPTIONAL fields
 
# Enable debug mode
# If true, http responses will have more detailed error information.
debug: true
 
# Environment variables
env:
  MY_VAR: "my-value123"
 
# CLI arguments passed to the binary
cli_args:
  - arg1
  - arg2
 
capabilities:
  # Fast startup with instaboot
  instaboot:
    requests:
      - path: /
      - path: /_bootstrap

Fields

Detailed description of all available fields.

kind

The kind field is used to identify the type of configuration file. It is required and is a constant set to wasmer.io/App.v0.

ℹ️

This constant field might be used in the future to support multiple configuration formats.

name

The name field is used to identify the name of the application. It is required and must be unique.

  • Required: true
  • Required format: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$

description

The description field is used to provide a description of the application. It is optional and can be any string.

  • Required: false

package

The package field is used to specify the name of the package to deploy. It is required and must specify a package published to the Wasmer registry.

Note: if you have a wasmer.toml in the same directory as the app.yaml, wasmer deploy will automatically prompt you to publish a new version of the package.

  • Required: true

env

Specify environment variables for the app. Must be a key-value map.

Example:

app.yaml
env:
  MY_VAR: "my-value123"
  • Required: false

cli_args

Specify command line arguments passed to the application.

Example:

app.yaml
cli_args:
  - arg1
  - arg2
  • Required: false

debug

The debug field is used to enable debug mode for the application. This in turn will show detailed error messages if a request fails, instead of a generic error. It is optional and can be any boolean.

  • Required: false
  • Default: false

capabilities

instaboot

Enable fast application startup with startup snapshots.

See InstaBoot for more details.

app.yaml
capabilities:
  instaboot:
    requests:
      - path: /
      - path: /_bootstrap
        # You can optionally speciy a maximum age.
        # If the maximum age is reached, a new snapshot will automatically
        # be created, and the old ones discarded
        max_age: 12h
 
        # Optionally request settings:
        method: POST
	body: "custom body"
	headers:
	- name: X-My-Header
	  value: my-value

health_checks

The health_checks field is used to check if an application is working correctly. If the healthchecks fail, edge will restart the application. It is optional and its an array of healtcheck objects

  • Required: false

Currently only supported healthcheck type is http. It executes an http request against the application. All the supported

Example healthcheck
app.yaml
health_checks:
  - http:
      method: get
      path: /
      interval: 30s
      timeout: 10s
      unhealthy_threshold: 2
      healthy_threshold: 1
      expected_status_codes:
        - 200
      # below are optional
      expected_body_includes: Hello World
      expected_body_regex: ".*Wasmer.*"

Fields for http healthcheck:

  • method: Required

    HTTP method to use.
  • path: Required

    Path to send request to.
  • interval: Required

    Duration between each request
  • timeout: Required

    Timeout duration for requests
  • unhealthy_threshold: Required

    After unhealthy_threshold amount of failure of the http requests, app is considered unhealthy and will be restarted
  • healthy_threshold: Required

    After healthy_threshold amount of failure of the http requests, app is considered healthy and will be restarted
  • expected_status_codes: Required

    If the application returns these status codes, then the request will be count as successful
  • expected_body_includes:

    If this is specified, response body should include the string defined in this field to be count as successful
  • expected_body_regex:

    If this is specified, response body should be able to match the regular expression defined in this field to be count as successful

So in the example above, if the application fails two consequent request, application will be restarted. It will be keep restarted until it successfully responds to one request

scaling

The scaling field is used to configure how your application scales on Edge.

scaling.mode

Scaling mode for the app.

NOTE: You should usually stick to the default behaviour, which is enabled when no scaling mode is specified. Only use the below modes if you you are sure they are appropriate!

Available values:

  • <unset>

    If no scaling mode is specified, Edge will send multiple requests to each instance, and also scale up additional instances if required. This is the default, and the recommended mode if your program can handle multiple requests concurrently (Rust, Go, ...).

  • single_concurrency

    Special scaling mode for apps that only support a single request at a time. You should enable this mode if your app can not handle multiple requests concurrently.

    Only a single request will be sent to each instance at a time. Edge will dynamically scale up additional instances of your app as required by the incoming request volume, and shut them down when they are no longer needed. This mode is appropriate for single-threaded synchronous Python/PHP/Ruby/...

Example:

app.yaml
scaling:
  mode: single_concurrency
  • Required: false