lib/k_manager/cli/watch.rb in k_manager-0.0.24 vs lib/k_manager/cli/watch.rb in k_manager-0.0.28
- old
+ new
@@ -25,19 +25,35 @@
builder_folder = absolute_path(builder_folder, Dir.pwd)
boot_file = absolute_path(boot_file, builder_folder)
log_params(builder_folder, boot_file) if log_level == 'debug'
- # puts builder_folder
- # puts boot_file
+ # If you do a System Exit (control+c) you can go into a reboot sequence based on options
+ # if the option is not set then system will exit gracefully
+ while keep_watching(builder_folder, boot_file); end
+ end
+ private
+
+ # rubocop:disable Metrics/AbcSize
+ def keep_watching(builder_folder, boot_file)
Dir.chdir(builder_folder) do
watcher = KManager::Watcher.new(builder_folder, boot_file)
watcher.start
end
- end
+ false
+ rescue Interrupt, SystemExit
+ if KManager.opts.reboot_on_kill == true || KManager.opts.reboot_on_kill == 1
+ puts "\nRebooting #{KManager.opts.app_name}..."
+ sleep KManager.opts.reboot_sleep unless KManager.opts.reboot_sleep.zero?
- private
+ return true
+ end
+
+ puts "\nExiting..."
+ false
+ end
+ # rubocop:enable Metrics/AbcSize
def log_params(builder_folder, boot_file)
log.section_heading('Watch project')
log.kv 'builder_folder' , builder_folder
log.kv 'boot_file' , boot_file