I'm a bit confused on how to do some of the config for Rpush when starting from the Rails environment. If I just want to Rpush.embed and run within this same process, where should I call Rpush.embed? Does this go in the initializer? I am also unclear on the best place to set up my apps. I see there is a nice feature for signaling rpush to re-read from the configured app, but where do I configure the app itself? I see that I can do this with active model calls, but I obviously don't want to create a new app everytime I start the rack (or rails).
Create apps using database migration, put Rpush.embed in config.ru
Related
As part of the security procedures for our Rails application, we want to have an audit log of the commands that were run from rails console in our production environment.
This audit log should be persisted somewhere, such as a database, a file in an S3 bucket, or similar. If it could be written to the standard rails log, that might be OK too, as we already have a way to persist that.
We're currently hosted on Heroku. Heroku will log the event of firing up a console, but (a) Heroku provides no functionality for logging commands run from an active console, and (b) we'd like a more general-purpose solution.
Are there any pre-existing solutions for this out there?
If there is none, I'm trying to figure out how to monkey-patch IRB or Rails Console.
I've discovered that the data I need is already in
Readline::HISTORY
but I'm struggling to figure out where/how to hook into it.
Ideally, I'd like to capture each entry as (before?) it is sent to the interpreter, and quickly persist it somewhere (we already have Resque, so that may be a good solution). FWIW, sending the contents of Readline::HISTORY on Kernel.exit seems like it may be unreliable. For example, if a SIGKILL stops the process, then the history contents wouldn't be saved.
I’ve got a Sinatra web app. I’m using Resque and Resque Scheduler, and now I’m looking into adding Resque Web to (hopefully) see what my Resque queue looks like. Now here’s my problem: the official Resque Web is a Rails app. I don’t know how to use a Rails app inside of Sinatra, or if it’s even possible.
So my question: What’s the best way to implement Resque Web into my Sinatra app? Can I use the rails app inside of Sinatra? I saw one person say that you should have a separate part of your app running Rails, but that seems really nasty. Is there a better way to do it?
Thanks!
I've not used the ResqueWeb, but Rails and Sinatra are both Rack compliant frameworks, so they should be able to run each other or alongside.
http://www.sinatrarb.com/intro.html#Rack%20Middleware
## my-amazing-app.rb
use MySlightlyLessAmazingRailsApp
# rest of Sinatra stuff…
or
# config.ru
map "/" do
# easiest to mount Sinatra apps this way if using the modular style
run MyAmazingSinatraApp
end
map "/resque" do
run MySlightlyLessAmazingRailsApp
end
I don't know how you'd do this with Rails, perhaps try this link http://m.onkey.org/rails-meets-sinatra or perhaps this:
RailsApp::Application.routes.draw do
mount MyAmazingApp, :at => "/more-amazed"
# rest of the rails routes
end
Here’s what I was looking for: http://asciicasts.com/episodes/271-resque
Resque-web can be stand alone, run from the command line. So I’m just starting it up with a shell command whenever I spin up an instance of my server. Not exactly what I was looking for, but it does the trick!
Thanks for the suggestions, all.
The main question is: Can I read Rails session data in Node?
More details:
I have a project that is written in Ruby on Rails. It works but I want to add to it and eventually replace it using NodeJS. Both are running on the same server, just on different ports.
As of now RoR will serve up all the HTML files (and continue handeling the existing functionality) and then I'll connect to the Node server via AJAX. Node will just dish up JSON for the time being.
The problem is, how can I work with session variables between the two? More specifically, can I get to RoRs session variables in Node? Mostly I just need to know which user is logged in.
If it matters, I am running Rails 2.3.5, Ruby 1.8.7, and Node 0.8.17.
I haven't tried exactly same stuff, myself, but, we did something similar but with Sinatra and Java.
I wouldn't comment about your approach on application design, but, in case you don't mind using Memcached session store in your rails application, yes it is possible. Configuring Memcached with Ruby app is explained on Heroku Doc
In Node application you can use Memcached Client like 3rd-Eden and access session variable from memcache
You would have to explicitly pass session id generated by rails to Node.
I have had a quick look on google to no avail.
I am looking for a way to write a rails app that can deploy another rails app using nginx unicorn and what ever else is necessary to get the job done.
Ideal the user would be presented with a screen where they would enter username password, email and sitename.
Then the app would create the site and give it the url sitename.appname.com
Thanks
Ash
They are called engineyard, and heroku.
Rails probably wouldn't do much but give you the control panel, all the magic would be behind the scenes. If you are just subdomaining an existing app, rails can do that too and you wouldn't need a new nginx/unicorn on each subdomain either.
The typical answer of "it depends on your app and there is not enough information to go on" applies as well.
I have inherited the maintenance of a legacy web-application with an "interesting" way to manage concurrent access to the database.
The application is based on ruby-on-rails 2.3.8.
I'd like to set up a development environment and from there have two web browser make simultaneous requests, just to get the gist of what is going on.
Of course this is not going to work if I use Webrick, since it services just one http request at a time, so all the requests are effectively serialized by it.
I thought that mongrel could help me, but
mongrel_rails start -n 5
is actually spawning a single process and it seems to be single-threaded, too.
What is the easiest way of setting my development environment so that it responds to more than one request at a time? I'd like to avoid using apache and mod_passenger because, this being development, I'd like to be able to change the code and have it reloaded automatically on the next request.
In development mode, mod_passenger does reload classes and views. I use passenger exclusively for both development and deployment.
In production, you can (from the root of the rails app):
touch tmp/restart.txt
and passenger will reload the app.
Take a look at thin
http://code.macournoyer.com/thin/