Skip to content

Commit

Permalink
chore(shard.yml): remove future.cr dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
stakach committed Nov 12, 2023
1 parent 8675967 commit 7668f12
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
7 changes: 2 additions & 5 deletions shard.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
name: action-controller
version: 7.2.3
version: 7.3.0
crystal: ">= 1.9.0"

dependencies:
future:
github: crystal-community/future.cr
version: ~> 1.0
habitat:
github: luckyframework/habitat
version: ~> 0.4
lucky_router:
github: luckyframework/lucky_router
version: ~> 0.4
version: ~> 0.5
exception_page:
github: crystal-loot/exception_page
version: ~> 0.3
Expand Down
1 change: 0 additions & 1 deletion src/action-controller.cr
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require "json-schema"
require "habitat"
require "future"
require "./action-controller/logger"

module ActionController
Expand Down
19 changes: 11 additions & 8 deletions src/action-controller/server.cr
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ class ActionController::Server

# create an instance of the application
def initialize(@port = 3000, @host = "127.0.0.1", @reuse_port : Bool = REUSE_DEFAULT)
@processes = [] of Future::Compute(Nil)
@processes = 0
@process_closed = Channel(Nil).new
init_routes
@socket = HTTP::Server.new(BEFORE_HANDLERS + [route_handler] + AFTER_HANDLERS)
end

# create an instance of the application with tls
def initialize(@ssl_context : OpenSSL::SSL::Context::Server?, @port = 3000, @host = "127.0.0.1", @reuse_port : Bool = REUSE_DEFAULT)
@processes = [] of Future::Compute(Nil)
@processes = 0
@process_closed = Channel(Nil).new
init_routes
@socket = HTTP::Server.new(BEFORE_HANDLERS + [route_handler] + AFTER_HANDLERS)
end
Expand All @@ -52,7 +54,6 @@ class ActionController::Server
# :nodoc:
def reload
return unless @socket.closed?
@processes.clear
@socket = HTTP::Server.new(BEFORE_HANDLERS + [route_handler] + AFTER_HANDLERS)
end

Expand Down Expand Up @@ -94,7 +95,7 @@ class ActionController::Server

# Terminates the application gracefully once any cluster processes have exited
def close : Nil
@processes.each(&.get)
@processes.times { @process_closed.receive }
@socket.close
end

Expand Down Expand Up @@ -135,7 +136,8 @@ class ActionController::Server

# Start the processes
(0_i64...count).each do
@processes << future do
@processes += 1
spawn do
process = uninitialized Process
Process.run(process_path, args,
input: Process::Redirect::Close,
Expand All @@ -151,7 +153,7 @@ class ActionController::Server
else
puts " ! worker process #{process.pid} failed with #{status.exit_status}"
end
nil
@process_closed.send nil
end
end
end
Expand All @@ -173,15 +175,16 @@ class ActionController::Server
processes << process
end

@processes = processes.size
processes.each do |process|
@processes << future do
spawn do
status = process.wait
if status.success?
puts " < worker #{process.pid} stopped"
else
puts " ! worker process #{process.pid} failed with #{status.exit_status}"
end
nil
@process_closed.send nil
end
end
end
Expand Down

0 comments on commit 7668f12

Please sign in to comment.