Comments (9)
I haven't tried Sidekiq myself. I assume Sidekiq::Web implements the #call()
method. I'll double check but you make need a wildcard for paths such as /sidekick/busy
. I'd be very glad to work with you on this and if you have some suggestions on what documentation would add value I'll get that in place too.
from agoo.
Will put together something in the examples tonight.
from agoo.
Fiddling around a little I came up with this:
Sidekiq::Web.set :sessions, false
Agoo::Server.handle(:GET, "/sidekiq", Sidekiq::Web)
Agoo::Server.handle(:GET, "/sidekiq/**", Sidekiq::Web)
If you turn up the logging with something like this:
Agoo::Log.configure(dir: '',
console: true,
classic: true,
colorize: true,
states: {
INFO: true,
DEBUG: false,
connect: true,
request: true,
response: true,
eval: true,
push: false,
})
you can see more of what is going on.
Sidekiq is getting the requests but it expects some authentication setup. Are you familiar with how to set up Sidekiq?
from agoo.
Hmm this leads me back to Not Found
errors.
Here are the additions i made:
...
Sidekiq::Web.set :sessions, false
Sidekiq::Web.use Rack::Session::Cookie
Sidekiq::Web.use Rack::Auth::Basic do |username, password|
username == 'hello' && password == 'world'
end
The first line sets a rack.session
cookie which I believe clears up the authentication issue https://github.com/mperham/sidekiq/blob/93bfa9d40ebd711e88ac32043306b5e1aa41b6cb/lib/sidekiq/web/csrf_protection.rb#L69
Maybe there's some extra steps required here but this is how I've always setup Sidekiq auth in Sinatra based applications. Judging by the fact the error is back to being a 404 I guess auth is working.
from agoo.
When logging is turned up you can see that the Not Found is coming from Sidekiq. Is there some other Sidekiq setup required? I can look at some other apps to see what additional steps they take if you can suggest a few. Sinatra might be a place to start if you say it works.
from agoo.
Typically its plug and play, the only real thing you need to so is set a route for Sidekiq::Web, even the authentication can be skipped if you dont mind public access.
This is very old but it's how I've setup another sinatra application so I guess not much has changed in 5 years https://github.com/p8952/sinatra-sidekiq
This might be helpful too https://www.netguru.com/codestories/first-steps-with-sinatra-part-2 (Jump to sidekiq section)
I'll try and do some digging as well. It's also a bit weird that the Sidekiq webpage does show up when the route is /
but not when it's /sidekiq
from agoo.
For me it didn't show up in either but I didn't have the auth set up correctly. I'll dig some more tonight. Day time job now. 😄
from agoo.
I added a branch named sidekiq-example
. In examples/sidekiq/main.rb is the code I am playing with. Here is what I have so far. Stats work. The problem I am running into now is lack of middleware to get past the session check. If you know how to configure that, great. If not then a wrapper class might be needed.
require 'agoo'
require 'sidekiq/web'
# Setting the thread count to 0 causes the server to use the current
# thread. Greater than zero runs the server in a separate thread and the
# current thread can be used for other tasks as long as it does not exit.
Agoo::Log.configure(dir: '',
console: true,
classic: true,
colorize: true,
states: {
INFO: true,
DEBUG: false,
connect: true,
request: true,
response: true,
eval: true,
push: false,
})
class Stat
def self.call(req)
stats = Sidekiq::Stats.new
workers = Sidekiq::Workers.new
content = %|
<p>Processed: #{stats.processed}</p>
<p>Enqueued: #{stats.enqueued}</p>
<p>In Progress: #{workers.size}</p>
<p><a href='/'>Refresh</a></p>
<p><a href='/add_job'>Add Job</a></p>
<p><a href='/sidekiq'>Dashboard</a></p>
|
[ 200, { }, [ content ] ]
end
end
Agoo::Server.init(6464, 'root', thread_count: 0)
Sidekiq::Web.set :sessions, false
Sidekiq::Web.use Rack::Session::Cookie
Sidekiq::Web.use Rack::Auth::Basic do |username, password|
username == 'hello' && password == 'world'
end
Sidekiq::Web.use Rack::Auth::Basic do |username, password|
[username, password] == [Settings.sidekiq.username, Settings.sidekiq.password]
end
Agoo::Server.handle(:GET, "/sidekiq", Sidekiq::Web)
Agoo::Server.handle(:GET, "/sidekiq/**", Sidekiq::Web)
Agoo::Server.handle(:GET, "/", Stat)
Agoo::Server.start()
from agoo.
Can this be closed?
from agoo.
Related Issues (20)
- Fragment usage HOT 17
- CORS issues HOT 8
- Agoo dumps core on malformed SDL HOT 5
- fails to launch in clustered mode HOT 17
- Agoo Fragment Cycle Security Vulnerability HOT 2
- Disabling introspection for GraphQL HOT 12
- Changes on args or req does not get fowarded to the other calls HOT 9
- Static asset with space in filename HOT 4
- gem install agoo fails on MacOS Ventura 13.2.1 HOT 9
- Static .txt files are not served with utf-8 encoding HOT 8
- Agoo crash and exit HOT 7
- CLI options for SSL/TLS HOT 3
- localhost is crashing as bind address HOT 4
- 502 via nginx proxy_pass HOT 3
- TypeError: no implicit conversion of Array into String HOT 2
- rackup -r agoo -s agoo Doesn't Work HOT 8
- Out of curiousity would anything have been lost or gained by using ABI, or FFI, or *.SO over the current API method of directly calling in the Ruby C file headers? HOT 3
- Configuring worker count and thread count when used with Rails HOT 5
- Port cleanup on shutdown? HOT 3
- REMOTE_ADDR not set on ENV HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from agoo.