Skip to content

Instantly share code, notes, and snippets.

@Industrial
Created June 27, 2020 13:49
Show Gist options
  • Save Industrial/ffa29e475270b4955f8fc41ebfeb0fd5 to your computer and use it in GitHub Desktop.
Save Industrial/ffa29e475270b4955f8fc41ebfeb0fd5 to your computer and use it in GitHub Desktop.
0.07s info: Falcon::Command::Serve [oid=0xc80] [pid=56072] [2020-06-27 15:48:04 +0200]
| Falcon v0.36.4 taking flight! Using Async::Container::Forked {:count=>1}.
| - Binding to: #<Falcon::Endpoint http://localhost:8080/ {}>
| - To terminate: Ctrl-C or kill 56072
| - To reload configuration: kill -HUP 56072
0.11s error: Async::Task [oid=0xc94] [pid=56073] [2020-06-27 15:48:04 +0200]
| NoMethodError: undefined method `run' for main:Object
| → /home/tom/Code/Code9/projects/ruby-test/src/runtime1.rb:8 in `<top (required)>'
| /home/tom/.rvm/gems/ruby-2.7.1/gems/rack-2.2.3/lib/rack/builder.rb:68 in `require'
| /home/tom/.rvm/gems/ruby-2.7.1/gems/rack-2.2.3/lib/rack/builder.rb:68 in `parse_file'
| /home/tom/.rvm/gems/ruby-2.7.1/gems/falcon-0.36.4/lib/falcon/command/serve.rb:86 in `load_app'
| /home/tom/.rvm/gems/ruby-2.7.1/gems/falcon-0.36.4/lib/falcon/controller/serve.rb:52 in `load_app'
| /home/tom/.rvm/gems/ruby-2.7.1/gems/falcon-0.36.4/lib/falcon/controller/serve.rb:75 in `block (2 levels) in setup'
| /home/tom/.rvm/gems/ruby-2.7.1/gems/async-1.26.2/lib/async/task.rb:258 in `block in make_fiber'
0.12s info: Async::Container::Forked [oid=0xcbc] [pid=56072] [2020-06-27 15:48:04 +0200]
| #<Async::Container::Process Falcon Server> exited with pid 56073 exit 0
#!/usr/bin/env -S falcon serve --bind http://localhost:8080 --count 1 -c
require 'async/websocket/adapters/rack'
require 'set'
$connections = Set.new
run lambda {|env|
Async::WebSocket::Adapters::Rack.open(env, protocols: ['ws']) do |connection|
$connections << connection
while message = connection.read
$connections.each do |connection|
connection.write(message)
connection.flush
end
end
ensure
$connections.delete(connection)
end or [200, {}, ["Hello World"]]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment