forked from YACS-RCOS/yacs-notifications
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed conflicts and incorporated Minja & Ada's Websocket config
- Loading branch information
Showing
11 changed files
with
108 additions
and
130,561 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,52 @@ | ||
require 'plezi' | ||
require 'iodine' | ||
require_relative 'app/controllers/eventstream' | ||
|
||
## Set environment, working directory, load gems and create logs | ||
#ENV['ENV'] ||= ENV['RACK_ENV'] ||= ENV['RAILS_ENV'] # production ENV will render SASS as compressed. | ||
## Using pathname extentions for setting public folder | ||
require 'pathname' | ||
## Set up root object, it might be used by the environment and\or the plezi extension gems. | ||
Root ||= Pathname.new(File.dirname(__FILE__)).expand_path | ||
## If this app is independant, use bundler to load gems (including the plezi gem). | ||
## otherwise, use the original app's Gemfile and Plezi will automatically switch to Rack mode. | ||
require 'bundler' | ||
Bundler.require(:default, ENV['ENV'].to_s.to_sym) | ||
# Load all the code from a subfolder called 'app' | ||
Dir[File.join '{controllers}', '**', '*.rb'].each { |file| load File.expand_path(file) } | ||
# Load all the code from a subfolder called 'lib' | ||
Dir[File.join '{lib}', '**', '*.rb'].each { |file| load File.expand_path(file) } | ||
|
||
|
||
#Setting the port | ||
#Iodine::DEFAULT_HTTP_ARGS[:port] = 4860 | ||
|
||
## Logging | ||
#::Iodine::DEFAULT_HTTP_ARGS[:log] = 1 if ::Iodine::DEFAULT_HTTP_ARGS[:log].nil? | ||
#Iodine::DEFAULT_HTTP_ARGS[:public] ||= './public' | ||
|
||
|
||
# # Optional Scaling (across processes or machines): | ||
ENV['PL_REDIS_URL'] ||= ENV['REDIS_URL'] || | ||
ENV['REDISCLOUD_URL'] || | ||
ENV['REDISTOGO_URL'] || | ||
nil # "redis://:[email protected]:6389/0" | ||
# # redis channel name should be changed IF using the same Plezi code within | ||
# # more then one application (i.e., using both Rails and Plezi together). | ||
# Plezi.app_name = 'yacs_websocket_a027e2d668a7dc21c59fe56f018432ea' | ||
|
||
# Map the views folder to the template root (for the {#render} function). | ||
#Plezi.templates = Root.join('views').to_s | ||
|
||
# load routes. | ||
load Root.join('routes.rb').to_s | ||
|
||
App = Proc.new do |env| | ||
if(env['rack.upgrade?'.freeze] == :websocket) | ||
env['rack.upgrade'.freeze] = EventStream.new | ||
[0, {}, []] | ||
else | ||
[200, {"Content-Length" => "12", "Content-Type" => "text/plain"}, ["Hello World!"]] | ||
end | ||
|
||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,7 @@ | ||
# Default Rack interface | ||
require 'plezi' | ||
require 'iodine' | ||
|
||
# encoding: UTF-8 | ||
# load the application | ||
## Set environment, working directory, load gems and create logs | ||
#ENV['ENV'] ||= ENV['RACK_ENV'] ||= ENV['RAILS_ENV'] # production ENV will render SASS as compressed. | ||
## Using pathname extentions for setting public folder | ||
require 'pathname' | ||
## Set up root object, it might be used by the environment and\or the plezi extension gems. | ||
Root ||= Pathname.new(File.dirname(__FILE__)).expand_path | ||
## If this app is independant, use bundler to load gems (including the plezi gem). | ||
## otherwise, use the original app's Gemfile and Plezi will automatically switch to Rack mode. | ||
require 'bundler' | ||
Bundler.require(:default, ENV['ENV'].to_s.to_sym) | ||
|
||
# Load all the code from a subfolder called 'app' | ||
Dir[File.join '{controllers}', '**', '*.rb'].each { |file| load File.expand_path(file) } | ||
# Load all the code from a subfolder called 'lib' | ||
Dir[File.join '{lib}', '**', '*.rb'].each { |file| load File.expand_path(file) } | ||
|
||
#Setting the port | ||
#Iodine::DEFAULT_HTTP_ARGS[:port] = 4860 | ||
|
||
## Logging | ||
#Iodine::DEFAULT_HTTP_ARGS[:log] = 1 if Iodine::DEFAULT_HTTP_ARGS[:log].nil? | ||
|
||
# # Optional Scaling (across processes or machines): | ||
ENV['PL_REDIS_URL'] ||= ENV['REDIS_URL'] || | ||
ENV['REDISCLOUD_URL'] || | ||
ENV['REDISTOGO_URL'] || | ||
nil # "redis://:[email protected]:6389/0" | ||
# # redis channel name should be changed IF using the same Plezi code within | ||
# # more then one application (i.e., using both Rails and Plezi together). | ||
# Plezi.app_name = 'yacs_websocket_a027e2d668a7dc21c59fe56f018432ea' | ||
|
||
# Map the views folder to the template root (for the {#render} function). | ||
#Plezi.templates = Root.join('views').to_s | ||
|
||
#module App | ||
# def self.call(env) | ||
# if(env['rack.upgrade?'.freeze] == :websocket) | ||
# env['rack.upgrade'.freeze] = EventStream.new | ||
# return [0, {}, []] | ||
# end | ||
# return [200, {"Content-Length" => "12", "Content-Type" => "text/plain"}, ["Hello World!"]] | ||
# end | ||
#end | ||
|
||
#run App | ||
#Iodine::DEFAULT_HTTP_ARGS[:public] ||= './public' | ||
load ::File.expand_path(File.join('..', 'app.rb'), __FILE__) | ||
|
||
run App | ||
run Plezi.app |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
nohup bundle exec iodine -p 4860 > iodine.out 2>&1 & | ||
nohup bundler exec iodine -p 4860 -www ./public -v > iodine.out 2>&1 & | ||
bundle exec karafka server |
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,20 @@ | ||
* Listening on port 4860 | ||
|
||
Server is running 2 workers X 2 threads, press ^C to stop | ||
Running Plezi version: 0.15.1 | ||
|
||
Starting up Iodine HTTP Server on port 4860: | ||
* Ruby v.2.5.1 | ||
* Iodine v.0.4.19 | ||
* 1048576 max concurrent connections / open files | ||
* Serving static files from ./public | ||
|
||
* 6 is running. | ||
* 14 is running. | ||
172.18.0.1 - - [Tue, 6 Aug 2018 03:14:14 GMT] "GET /notifications HTTP/1.1" 101 -- 300ms | ||
Iodine caught an unprotected exception - LocalJumpError: no block given | ||
/usr/src/app/app/controllers/eventstream.rb:12:in `subscribe' | ||
/usr/src/app/app/controllers/eventstream.rb:12:in `on_open' | ||
Iodine caught an unprotected exception - TypeError: wrong argument type String (expected Hash) | ||
/usr/src/app/app/controllers/eventstream.rb:26:in `publish' | ||
/usr/src/app/app/controllers/eventstream.rb:26:in `on_close' |
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
Oops, something went wrong.