title = "The Spin Command Trigger" template = "spin_main" date = "2025-01-09T00:00:01Z" enable_shortcodes = true [extra] url = "https://github.com/fermyon/developer/blob/main/content/spin/v3/command-trigger.md"
- Installing the Command Trigger
- Creating the Application
- Learn more about the Spin Command Trigger
- Additional Spin Triggers
Spin has experimental support for creating and running components once. Please note that there are only working Command trigger app samples written in Rust at present.
Please note: You can not
spin deployan application to Fermyon Cloud if it usescommandbecause non-HTTP triggers are not supported in Fermyon Cloud.
Let's look at how the experimental Command trigger for Spin allows you to deploy an application that runs once to completion. The Command trigger specification references a specific component. For example:
[[trigger.command]]
component = "hello"First, we install the plugin:
spin plugins update
spin plugin install trigger-commandThen, we install the template:
spin templates install --git https://github.com/fermyon/spin-trigger-commandWith the plugin and template installed, we create a new application:
spin new -t command-rust hello --accept-defaultsThe Rust source code for this application is as follows:
fn main() {
println!("Hello, Fermyon!");
}We can immediately run this pre-written (template) application and observe the time-driven execution:
cd hello
spin build --up
Building component hello with `cargo build --target wasm32-wasi --release`
...
Finished building all Spin components
Hello, Fermyon!As we can see from the above output, our application is executed once to completion without the need for any incoming requests.
<iframe width="560" height="315" src="https://www.youtube.com/embed/l2nh_xpjCiM?si=fBPaiqoIkJPQ95W_" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>If you would like to learn more about using the Spin Command Trigger, please check out the Spin Command Trigger GitHub repository.
You can leverage different triggers as part of your Spin apps to address common requirements and build real-world, distributed applications with Spin.
The incredible Spin and SpinKube community, also provides the following, additional Spin triggers: