Skip to content

Commit

Permalink
stay shutdown if there is no reason to launch
Browse files Browse the repository at this point in the history
  • Loading branch information
stakach committed Feb 18, 2025
1 parent 0ab6e6b commit 1319a82
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/placeos-driver/protocol/management.cr
Original file line number Diff line number Diff line change
Expand Up @@ -439,13 +439,20 @@ class PlaceOS::Driver::Protocol::Management
# this executes once the driver has exited
status = $?
request_lock.synchronize { @running = false }
@pid = -1_i64
@proc = nil
@last_exit_code = exit_code = status.exit_code
File.delete(unix_socket) rescue nil
Log.info { {message: "driver process exited with #{exit_code}", driver_path: @driver_path} } unless status.success?
rescue error
Log.error(exception: error) { "error launching driver: #{@driver_path}" }
ensure
sleep 1.second
launch_driver_failed
@io.try(&.close) rescue nil
@io = nil
if !modules.empty?
sleep 200.milliseconds
launch_driver_failed
end
end

private def launch_driver_failed
Expand Down

0 comments on commit 1319a82

Please sign in to comment.