watch_restart Module

Supervisor and auto-restart support.

When enabled, fpm-watch can run under a supervisor loop that restarts the watcher on failure (non-zero exit status).

Configuration sources: - CLI flags: - --watch-auto-restart - --watch-restart-delay <sec> - --watch-restart-max <n> - --watch-self <path> - fpm.toml [extra.fpm-watch] keys: - auto-restart, restart-delay, restart-max, self / self-exe

Low CPU mode is also applied here so the supervisor delay sleeps are idle.


Uses

  • module~~watch_restart~~UsesGraph module~watch_restart watch_restart iso_fortran_env iso_fortran_env module~watch_restart->iso_fortran_env module~watch_cmdline watch_cmdline module~watch_restart->module~watch_cmdline module~watch_config watch_config module~watch_restart->module~watch_config module~watch_time watch_time module~watch_restart->module~watch_time fpm_environment fpm_environment module~watch_cmdline->fpm_environment fpm_error fpm_error module~watch_config->fpm_error fpm_filesystem fpm_filesystem module~watch_config->fpm_filesystem fpm_strings fpm_strings module~watch_config->fpm_strings fpm_toml fpm_toml module~watch_config->fpm_toml module~watch_types watch_types module~watch_config->module~watch_types tomlf tomlf module~watch_config->tomlf module~watch_time->iso_fortran_env module~watch_time->fpm_environment iso_c_binding iso_c_binding module~watch_time->iso_c_binding module~watch_types->iso_fortran_env module~watch_types->fpm_strings fpm_command_line fpm_command_line module~watch_types->fpm_command_line

Functions

private function build_child_command(exe0) result(cmd)

Build the command line used to spawn the supervised child.

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: exe0

Return Value character(len=:), allocatable

private function choose_self_exe(exe0) result(exe)

Determine the executable to use when spawning the child watcher.

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: exe0

Return Value character(len=:), allocatable


Subroutines

public subroutine maybe_supervise()

Enter supervisor mode when requested, otherwise return immediately.

Read more…

Arguments

None

private subroutine parse_restart_flags(auto_restart, restart_delay, restart_max, is_child, self_exe)

Parse restart-related flags and apply manifest defaults.

Read more…

Arguments

Type IntentOptional Attributes Name
logical, intent(out) :: auto_restart
real, intent(out) :: restart_delay
integer, intent(out) :: restart_max
logical, intent(out) :: is_child
character(len=:), intent(out), allocatable :: self_exe

private subroutine supervisor_loop(delay0, max0, exe0)

Run the supervisor loop, restarting the child on non-zero exit.

Read more…

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: delay0
integer, intent(in) :: max0
character(len=*), intent(in) :: exe0