diff --git a/PACKAGING.md b/PACKAGING.md index 4a5f47445..f6a98b218 100644 --- a/PACKAGING.md +++ b/PACKAGING.md @@ -46,3 +46,9 @@ * `libwasmer-static`, containing `libwasmer.a`. The Wasmer distro packaging story is still in its infancy, so feedback is very welcome. + +## Miscellaneous: binfmt_misc + +Wasmer can be registered as a binfmt interpreter for wasm binaries. +An example systemd [.service](./scripts/wasmer-binfmt.service.example) is included here. +Please consider statically linking the wasmer binary so that this capability is also available in mount namespaces. diff --git a/lib/cli/src/commands/binfmt.rs b/lib/cli/src/commands/binfmt.rs index d5c96709b..97cd8137a 100644 --- a/lib/cli/src/commands/binfmt.rs +++ b/lib/cli/src/commands/binfmt.rs @@ -19,6 +19,9 @@ enum Action { } /// Unregister and/or register wasmer as binfmt interpreter +/// +/// Check the wasmer repository for a systemd service definition example +/// to automate the process at start-up. #[derive(StructOpt)] pub struct Binfmt { // Might be better to traverse the mount list diff --git a/scripts/wasmer-binfmt.service.example b/scripts/wasmer-binfmt.service.example new file mode 100644 index 000000000..414aef70f --- /dev/null +++ b/scripts/wasmer-binfmt.service.example @@ -0,0 +1,15 @@ +[Unit] +Description=Set up wasmer to handle execution of wasm binaries +DefaultDependencies=no +Conflicts=shutdown.target +After=proc-sys-fs-binfmt_misc.automount +After=proc-sys-fs-binfmt_misc.mount +Before=sysinit.target shutdown.target +ConditionPathIsReadWrite=/proc/sys/ + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/bin/wasmer binfmt reregister +ExecStop=/usr/bin/wasmer binfmt unregister +TimeoutSec=10s