mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 10:55:30 -04:00
Fix CLI tool not exiting
This commit is contained in:
parent
99a77966ad
commit
c07f421322
@ -6,6 +6,7 @@
|
||||
class MainFiber
|
||||
@@channel = Channel(-> Nil).new
|
||||
@@done = Channel(Bool).new
|
||||
@@main_fiber = Fiber.current
|
||||
|
||||
def self.start_and_block
|
||||
loop do
|
||||
@ -21,9 +22,13 @@ class MainFiber
|
||||
end
|
||||
|
||||
def self.run(&block : -> Nil)
|
||||
@@channel.send block
|
||||
until @@done.receive
|
||||
Fiber.yield
|
||||
if @@main_fiber == Fiber.current
|
||||
block.call
|
||||
else
|
||||
@@channel.send block
|
||||
until @@done.receive
|
||||
Fiber.yield
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
21
src/mango.cr
21
src/mango.cr
@ -45,17 +45,22 @@ class CLI < Clim
|
||||
version "Version #{MANGO_VERSION}", short: "-v"
|
||||
common_option
|
||||
run do |opts|
|
||||
Config.load(opts.config).set_current
|
||||
MangaDex::Downloader.default
|
||||
Plugin::Downloader.default
|
||||
|
||||
puts BANNER
|
||||
puts DESCRIPTION
|
||||
puts
|
||||
|
||||
# empty ARGV so it won't be passed to Kemal
|
||||
ARGV.clear
|
||||
Server.new.start
|
||||
|
||||
Config.load(opts.config).set_current
|
||||
MangaDex::Downloader.default
|
||||
Plugin::Downloader.default
|
||||
|
||||
spawn do
|
||||
Server.new.start
|
||||
end
|
||||
|
||||
MainFiber.start_and_block
|
||||
end
|
||||
|
||||
sub "admin" do
|
||||
@ -123,8 +128,4 @@ class CLI < Clim
|
||||
end
|
||||
end
|
||||
|
||||
spawn do
|
||||
CLI.start(ARGV)
|
||||
end
|
||||
|
||||
MainFiber.start_and_block
|
||||
CLI.start(ARGV)
|
||||
|
Loading…
x
Reference in New Issue
Block a user