-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
186 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "async-container", path: "../" | ||
gem "debug" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
PATH | ||
remote: .. | ||
specs: | ||
async-container (0.18.3) | ||
async (~> 2.10) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
async (2.21.1) | ||
console (~> 1.29) | ||
fiber-annotation | ||
io-event (~> 1.6, >= 1.6.5) | ||
console (1.29.0) | ||
fiber-annotation | ||
fiber-local (~> 1.1) | ||
json | ||
date (3.4.1) | ||
debug (1.9.2) | ||
irb (~> 1.10) | ||
reline (>= 0.3.8) | ||
fiber-annotation (0.2.0) | ||
fiber-local (1.1.0) | ||
fiber-storage | ||
fiber-storage (1.0.0) | ||
io-console (0.8.0) | ||
io-event (1.7.4) | ||
irb (1.14.1) | ||
rdoc (>= 4.0.0) | ||
reline (>= 0.4.2) | ||
json (2.9.0) | ||
psych (5.2.1) | ||
date | ||
stringio | ||
rdoc (6.8.1) | ||
psych (>= 4.0.0) | ||
reline (0.5.12) | ||
io-console (~> 0.5) | ||
stringio (3.1.2) | ||
|
||
PLATFORMS | ||
arm64-darwin-22 | ||
ruby | ||
|
||
DEPENDENCIES | ||
async-container! | ||
debug | ||
|
||
BUNDLED WITH | ||
2.5.22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
require "console" | ||
|
||
Console.logger.debug! | ||
|
||
class Jobs | ||
LOG_FILE = File.join(Dir.pwd, "jobs.log") | ||
|
||
def self.start = self.new.start | ||
|
||
def start | ||
Console.debug(self, "Starting jobs...") | ||
|
||
loop do | ||
Console.info(self, "Jobs running...") | ||
|
||
sleep 1 | ||
end | ||
rescue Interrupt | ||
Console.debug(self, "Exiting jobs...") | ||
exit | ||
end | ||
end | ||
|
||
Jobs.start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
require "async/container" | ||
require "console" | ||
require "debug" | ||
|
||
# container = Async::Container.new | ||
|
||
# container.spawn(name: "Web") do |task| | ||
# task.exec("bundle", "exec", "web") | ||
# end | ||
|
||
# container.spawn(name: "Jobs") do |task| | ||
# task.exec("bundle", "exec", "jobs") | ||
# end | ||
|
||
Console.logger.debug! | ||
|
||
class WebController < Async::Container::Controller | ||
def setup(container) | ||
container.spawn(name: "Web") do |instance| | ||
instance.exec("bundle", "exec", "web") | ||
end | ||
|
||
# container.spawn(name: "Jobs") do |instance| | ||
# instance.exec("bundle", "exec", "jobs") | ||
# end | ||
end | ||
end | ||
|
||
class App | ||
def self.start = self.new.start | ||
|
||
def start | ||
Console.debug(self, "Starting container...") | ||
|
||
web_controller = WebController.new | ||
web_controller.run | ||
end | ||
end | ||
|
||
pid = Process.pid | ||
pgid = Process.getpgid(pid) | ||
|
||
Thread.new do | ||
sleep 5 | ||
Console.debug(self, "Sending HUP signal to restart container...") | ||
Process.kill("HUP", -pgid) | ||
|
||
# sleep 5 | ||
# Console.debug(self, "Sending INT signal to stop container...") | ||
# Process.kill("INT", Process.pid) | ||
end | ||
|
||
App.start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
require "console" | ||
|
||
Console.logger.debug! | ||
|
||
class Web | ||
LOG_FILE = File.join(Dir.pwd, "web.log") | ||
|
||
def self.start = self.new.start | ||
|
||
def start | ||
Console.debug(self, "Starting web...") | ||
|
||
loop do | ||
Console.info(self, "Web running...") | ||
|
||
sleep 1 | ||
end | ||
rescue Interrupt | ||
Console.debug(self, "Exiting web...") | ||
exit | ||
end | ||
end | ||
|
||
Web.start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters