Skip to content

Commit

Permalink
Update manage_child_processes.md
Browse files Browse the repository at this point in the history
  • Loading branch information
nick1udwig authored Jun 13, 2024
1 parent 8e82bc8 commit b0293c5
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/cookbook/manage_child_processes.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ my-package/
│ ├─ Cargo.toml
│ ├─ Cargo.lock
```
To initiate a child process, use the `spawn` function from `kinode_process_lib`.
To start a child process, use the `spawn` function from `kinode_process_lib`.
The following example demonstrates a basic parent process whose sole function is to spawn a child process and grant it the ability to send messages using `http_client`:
```rust
// imports
use kinode_process_lib::{call_init, println, spawn, Address, Capability, OnExit};

// boilerplate to generate types
wit_bindgen::generate!({
path: "wit",
world: "process",
path: "target/wit",
world: "process-v0",
});

// parent app component boilerplate
Expand All @@ -44,7 +44,7 @@ fn init(our: Address) {
// name of the child process
Some("spawned_child_process".to_string()),
// path to find the compiled Wasm file for the child process
"/child.wasm",
&format!("{}/pkg/child.wasm", our.package_id()),
// what to do when this process crashes/panics/finishes
OnExit::None,
// capabilities to pass onto the child
Expand Down Expand Up @@ -74,9 +74,8 @@ The child process can be anything, for simplicity's sake let's make it a degener
use kinode_process_lib::{call_init, println, Address};

wit_bindgen::generate!({
// note that the WIT file can be in any directory
path: "wit",
world: "process",
path: "target/wit",
world: "process-v0",
});

call_init!(init);
Expand All @@ -93,7 +92,6 @@ The spawn function in Kinode comprises several parameters, each serving a specif
If set to None, the process is automatically assigned a numerical identifier, resulting in a ProcessId formatted like `123456789:my-package:john.os`.

- `wasm_path: String`: Indicates the location of the compiled WebAssembly (Wasm) bytecode for the process.
This path should be relative to the `/pkg` directory in your project.

- `on_exit: OnExit`: Determines the behavior of the process upon termination, whether due to completion, a crash, or a panic.
OnExit is an enum with three potential values:
Expand Down

0 comments on commit b0293c5

Please sign in to comment.