#[main]Expand description
Runs an async function on the ntex runtime.
Re-exported as ntex::main.
The function becomes a normal blocking function. When called, it builds a
System, runs the body to completion and returns its result, so the
function can return a value, for example std::io::Result<()>. It does
not have to be main.
#[ntex::main]
async fn main() -> std::io::Result<()> {
println!("Hello world");
Ok(())
}ยงArguments
name = "..."- name of the system. Defaults to the function name.signals = true/false- handle process signals. Off by default.fatal_signals = true/false- reportSIGSEGVandSIGABRTasSignal::Panic, the process still terminates. Unix only, only useful together withsignals = true. Off by default.panic_handling = true/false- report application panics asSignal::Panic. Only useful together withsignals = true. Off by default.ping_interval = N- how often, in milliseconds, the system pings its arbiters to spot busy ones. Defaults to 2000, zero turns pings off.timer_resolution = N- resolution of the timer wheel in milliseconds, a power of two between 1 and 16. Defaults to 16.thread_pool = N- maximum number of blocking thread-pool workers, passed toBuilder::thread_pool_limit. Defaults to 64 per arbiter.task_callbacks = path- afn() -> ntex::rt::TaskCallbacksfactory for instrumenting spawned tasks, passed toBuilder::task_callbacks. It is called on every thread of the system. None by default.rt = path- the runtime to run on, a value that implementsntex::rt::Runner. Defaults tontex::rt::DefaultRuntime, the runtime picked by ntex features.
#[ntex::main(name = "server", signals = true, ping_interval = 250)]
async fn main() {
println!("Hello world");
}