Rails check application - ruby

I have rails3 application and want to check it every few hours (cron)
verify database connection, free disk space ,etc...
What else should I check ?
Also is there a special gem for creating some kind of test controller with all I need, or shoul I create it myself?

rather than try and build your own analysis tools, you should try and use what rails provides you.
http://rails-analyzer.rubyforge.org/pl_analyze/
http://rails-analyzer.rubyforge.org/tools/
Although new relic is the best web based monitoring tool for rails you could try some alternatives.
http://drewblas.com/2008/05/29/comparison-of-rails-monitoring-apps/

Related

Removing all database access capability from rails 5.x client app

I am still fairly new to ruby and Ruby on Rails framework.
Rails --api only project is great for just getting into bare bones rest API development without any of the unneeded extras.
I would always build a web API app to handle my data access and domain logic.
I would create a separate rails app for the front end web client. Maybe this seperation of tiers is not always necessary for small or 'pet' projects but I prefer this architecture.
I am trying to find the best way to remove the data access related code and gems from my client project as I will never access the database.
Is there aclean way to do this automatically in a similar way that --api switch includes only things relevant to API app?
It's not the end of the world doing this manually but it would be nice if I could write a bash script that I can pass a project name and it would build me 2 shell projects - 1 API, 1 client - with only the things I would usually need at each level.
Any suggestions about this are greatly appreciated.
Thanks in advance!

Can I create a simple website to accept input and display, without Rails, database or external web server?

I am trying to see if I can create a simple website, like a blog, using only Ruby. No Rails or a database or outside web servers. I plan to store the data in a file for persistence.
I wanted to use TCPServer, CGI, and Net::HTTP.
Is there an easier way I can use?
There are a lot of moving parts when designing a website.
Depending on the purpose of the exercise, you might want to consider using a very simple web framework like Camping, Sinatra, or Ramaze. This is probably the best solution if you're trying to get a top level understanding of web programming because it only has exactly what you need (Camping is less than 4k!) and handles stuff like routing.
Building a web server is more an exercise in HTTP parsing. You might want to omit the framework and try to build something on top of Rake (an API for lots of popular web servers) and a simple web server like Webrick or Thin.
You could also try Espresso
It is easy to learn and fast to run.
And offers all the liberty you need for creation process.
Also it has no hidden "fees", everything is transparent.

How to Monitor ruby process ?

What is the best way to monitore Ruby process ( Not Rails ), I tried to use Newrelic but it seems it is designed for Rails .
I'm using distributed Ruby processes with foreman, the processes communicate with RabbitMQ queuing system, and I'm looking for a tool that can trace my queries and other parameters specially that I'm using active record with most of my models .
NewRelic is still viable for Ruby apps that are non-Rails. The downside is you have to manually instrument your code with trace calls. NewRelic's documentation (scroll down to Adding Method Tracers (Ruby)) shows how to setup custom tracing for your application. Then you can use the NewRelic website as usual to inspect the runtime of your app.
I have done this for Java apps, but not a Ruby app. One thing to look out for is that custom traces will show up in the Background Issues area, not under Web Transactions (for obvious reasons). Database calls should be in the correct area.
The NewRelic support is very good, I have work with them several times to debug an issue. If you have an issue with the custom tracing, they will help sort it out.
try monit

Free Ruby scheduled tasks (off the rails) hosting?

I have some simple Ruby scripts to run as a background job. They are in an infinite while loop to monitor external database changes. Can someone recommend a hosting provider that can do it for free to start?
I looked at AWS and the EC2 micro instance is actually a good fit for the first year. Anything equivalent beyond the first year?
Then I looked at Heroku. It seems a hack and overkill to use Delayed Job in the Rails framework.
Google App Engine is also a good fit as long as I am willing to rewrite my Ruby scripts to Python.
More background on my project. I am using CouchDB + CouchApp. It requires some external scripts to monitor new users sign up and send out forget password emails.
I don't know about free, but there is SimpleWorker, which lets you offload processes (and apparently schedule them too!) to their cloud infrastructure.
Try using http://callmyapp.com
Are you able to set up an always on machine at your house? It's probably going to be just as reliable as hosting it with a free tier provider.

How to use activerecord alone?

I prepare to develop one project, which has no UI. The project just need to interact with database, so is there any example for reference ?
Does your app have ties to a Rails-based app and need to read the Rails configuration files? Or, is it entirely stand-alone and have no Rails interaction?
ActiveRecord is OK for that, but if I don't need Rails compatibility I use Sequel. It's a great ORM that I find to be much more flexible.
If you need Rails compatibility and want to use ActiveRecord, look into using rails runner. From the docs:
runner runs Ruby code in the context of Rails non-interactively. For instance:
$ rails runner "Model.long_running_method"
Rails runner is for command-line apps that don't need the HTTPd server or user-interface of Rails. I use them for things like an app that runs daily to ftp files from a site for analysis. It has to write to the database, so it has access to all the models I've defined, but it never needs to present anything to the user since it is invisible to them.

Resources