rustexecinotifyrust-axum

Can a Rust executable recompile and re-execute itself?


While doing development in Rust/Axum/Askana (which compiles templates at compile time) it would be very useful if the server executable could, during development:

Is there already a way of doing this (on Linux) perhaps by another means?

Alternatively, perhaps there is a way of having Askana template files processed at request time during development, but still compiled into the executable for release? (I would still like to see template compilation errors during development though.)


Solution

  • cargo watch seems to be what you're looking for.

    -x, --exec ... Cargo command(s) to execute on changes [default: check]

    So you'd probably use -x run (or -x run -r, and whatever additional parameters you need).

    And for the waiting part there is

    -d, --delay File updates debounce delay in seconds [default: 0.5]

    Since it's a server, the corresponding section would probably be of interest.