-
-
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
6 changed files
with
107 additions
and
0 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,17 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
require "async/container" | ||
require "console" | ||
|
||
# Console.logger.debug! | ||
|
||
class Application < Async::Container::Controller | ||
def setup(container) | ||
container.spawn(name: "Web") do |instance| | ||
instance.exec("bundle", "exec", "puma", "-C", "puma.rb", ready: false) | ||
end | ||
end | ||
end | ||
|
||
Application.new.run |
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,3 @@ | ||
run do |env| | ||
[200, {"content-type" => "text/plain"}, ["Hello World"]] | ||
end |
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,39 @@ | ||
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.2) | ||
fiber-annotation | ||
fiber-local (~> 1.1) | ||
json | ||
fiber-annotation (0.2.0) | ||
fiber-local (1.1.0) | ||
fiber-storage | ||
fiber-storage (1.0.0) | ||
io-event (1.7.5) | ||
json (2.9.1) | ||
nio4r (2.7.4) | ||
puma (6.5.0) | ||
nio4r (~> 2.0) | ||
rack (3.1.8) | ||
|
||
PLATFORMS | ||
ruby | ||
x86_64-linux | ||
|
||
DEPENDENCIES | ||
async-container! | ||
puma | ||
rack (~> 3) | ||
|
||
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,6 @@ | ||
source "https://rubygems.org" | ||
|
||
gem "async-container", path: "../.." | ||
|
||
gem "puma" | ||
gem "rack", "~> 3" |
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 @@ | ||
on_booted do | ||
require "async/container/notify" | ||
|
||
notify = Async::Container::Notify.open! | ||
notify.ready! | ||
end |
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,36 @@ | ||
# Puma Example | ||
|
||
This example shows how to start Puma in a container, using `on_boot` for process readiness. | ||
|
||
## Usage | ||
|
||
``` | ||
> bundle exec ./application.rb | ||
0.0s info: Async::Container::Notify::Console [oid=0x474] [ec=0x488] [pid=196250] [2024-12-22 16:53:08 +1300] | ||
| {:status=>"Initializing..."} | ||
0.0s info: Application [oid=0x4b0] [ec=0x488] [pid=196250] [2024-12-22 16:53:08 +1300] | ||
| Controller starting... | ||
Puma starting in single mode... | ||
* Puma version: 6.5.0 ("Sky's Version") | ||
* Ruby version: ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux] | ||
* Min threads: 0 | ||
* Max threads: 5 | ||
* Environment: development | ||
* PID: 196252 | ||
* Listening on http://0.0.0.0:9292 | ||
Use Ctrl-C to stop | ||
0.12s info: Async::Container::Notify::Console [oid=0x474] [ec=0x488] [pid=196250] [2024-12-22 16:53:08 +1300] | ||
| {:ready=>true} | ||
0.12s info: Application [oid=0x4b0] [ec=0x488] [pid=196250] [2024-12-22 16:53:08 +1300] | ||
| Controller started... | ||
^C21.62s info: Async::Container::Group [oid=0x4ec] [ec=0x488] [pid=196250] [2024-12-22 16:53:30 +1300] | ||
| Stopping all processes... | ||
| { | ||
| "timeout": true | ||
| } | ||
21.62s info: Async::Container::Group [oid=0x4ec] [ec=0x488] [pid=196250] [2024-12-22 16:53:30 +1300] | ||
| Sending interrupt to 1 running processes... | ||
- Gracefully stopping, waiting for requests to finish | ||
=== puma shutdown: 2024-12-22 16:53:30 +1300 === | ||
- Goodbye! | ||
``` |