Running mongrel_rails cluster::start on Windows - ruby-on-rails

I have managed to get mongrel_cluster running on my Windows server (v 1.0.5) ok, but I am having trouble trying to get it to spawning all of the (4) mongrel instances.
It launches the first one ok, but then does no more. That one instance serves just fine, but the others are not launched. I assume that this is becasue of: "** WARNING: Win32 does not support daemon mode." so its not forking the processes for each instance.
Is there a work arround for this? Even if I have to start 4 'mongrel_rails cluster::start' manually, thats ok (assumming that they start the correct node of the cluster), or am I better off just launching 4 normal (and speerate) mongrel instances?
I have 2 primary questions:
Is there a way to solve this?
What cool features will I loose by not using mongrel_cluster?

It turns out that you simply CANNOT do what I want to do. Instead you need to install the mongrel_service gem and run seperate mongrel instances as system services and balance on those.

Related

Why does the ruby process continue to exist after the foreman finishes?

I'm running two Rails applications (one of which depends on the other (API)) on a local development machine for development.
Applications are relatively fat, with webpack and so on. Therefore, I closed my eyes to the fact that the Macbook Pro turns on the cooling at a sufficiently strong level.
The problem is that the cooling continued to work after I exited the foreman (responsible for starting and running applications). Recently I noticed that this is due to two ruby processes (from two applications), which do not stop working after the foreman finishes. They continue to exist further, and monitoring shows that they load the processor for a couple at 100%.
I'm currently solving the problem like this:
Foreman -> Control + C
spring stop for ruby process
Can you please tell me how can I solve this problem without a spring stop crutch?
UPD
Using overmind there is no such problem. When overmind exits, the ruby process also exits. But using overmind can't run two projects at the same time. So this utility isn't a solution.

How do I setup multiple rails applications for development?

For the site I am currently working on we have 2 Rails 3.2 projects. One project is basically an API, and the other is a web front end. In order to develop on the web front end I need to have the API project running. I've tried using the foreman and subcontractor gems to manage this but it doesn't seem to work. Both projects run the Thin application server and have their own RVM gemsets. We also run Nginx in production.
How would you go about managing this setup for development? I want there to be 1 command to fire up everything, similar to how Foreman works.
Requirements:
RVM Support
Thin for development
One command I can run from the API application to start both applications
Cannot using Pow (it always seems to get hung up and is incredibly slow)
Setup should work for other developers with minimal setup (easily scriptable)
Works on OSX
Thanks!
tmuxinator allows you to easily configure a tmux session that can be launched with a single command containing any number of windows (tabs) and executes commands in each window (like starting a server). Just configure it to load the appropriate gemset for the appropriate rails server.
https://github.com/aziz/tmuxinator
another, very cool alternative to the tools you've mentioned is Invoker.
it's worth checking out, as it allows to run multiple processes at once (as well as terminate them), like foreman does and it offers .dev domain which mimics pow behavior.

Run thin webserver as a windows service

i'm trying to deploy in production Redmine application. I heard that thin is the fastest ruby on rails webserver so I installed it. Now I have a really simple problem: i must start it every time i reboot the machine via cmd because there isn't a prebuilt windows service or something similar that allow me to autostart it. How could i fix the problem? I saw that there is a bat file, so i tried to make a C# windows service like this and it starts correctly but if I stop it the service stops but the webserver is still active and it will never shutdown. The only way to stop thin is to reboot the machine. Maybe I'm wrong, could someone post an example of how should i run thin as a windows service?
i've written a blogpost about this a while ago, but most of it should still be applicable. Hope it helps.
But to be honest, i always deploy on windows using the mongrel-service gem, and configure an apache in front to load-balance between 3 mongrels. Much easier.
Also the big advantage for me was that if something went wrong with thin-service, it didn't restart automatically, while the mongrel-service guards your mongrel process, and if it for whatever reason goes down, it will restart it again. For me that was something i could not miss.

How to make/monitor/deploy daemon processes in JRuby

I'm currently porting a Rails App currently using REE to JRuby so I can offer an easy-to-install JRuby alternative.
I've bundled the app into a WAR file using Bundler which I'm currently deploying to GlassFish. However, this app has a couple of daemon processes and it would be ideal if these could be part of the WAR file, and potentially monitored by Glassfish (if possible).
I've looked at QuartzScheduler, and while meets my needs for a couple of things, I have a daemon process that must execute every 20 seconds as it's polling the database for any delayed mail to send.
If anyone can provide any insight as to how best to set up daemon processes in a JRuby/Java/Glassfish environment any help will be greatly appreciated! :)
One way to daemonize a JRuby process is to use akuma framework (on *nix) or others.
I would rather use cronjobs (schedulling) rather than daemons as they are less error-proned, daemons can leak memory, can stop on errors etc. Check jruby-quartz and quartz_scheduler
EDIT
If one uses Torquebox it offers support for services and scheduling.

modrails - rogue ruby processes consuming 100% cpu

I'm having ruby instances from mod_rails go "rogue" -- these processes are no longer listed in passenger-status and utilize 100% cpu.
Other than installing god/monit to kill the instance, can anyone give me some advice on how to prevent this? I haven't been able to find anything in the logs that helps.
If you're using Linux, you can install the "strace" utility to see what the Ruby process is doing that's consuming all the CPU. That will give you a good low-level view. It should be available in your package manager. Then you can:
$ sudo strace -p 22710
Process 22710 attached - interrupt to quit
...lots of stuff...
(press Ctrl+C)
Then, if you want to stop the process in the middle and dump a stack trace, you can follow the guide on using GDB in Ruby at http://eigenclass.org/hiki.rb?ruby+live+process+introspection, specifically doing:
gdb --pid=(ruby process)
session-ruby
stdout_redirect
(in other terminal) tail -f /tmp/ruby_debug.(pid)
eval "caller"
You can also use the ruby-debug Gem to remotely connect to debug sockets you open up, described in http://duckpunching.com/passenger-mod_rails-for-development-now-with-debugger
There also seems to be a project on Github concerned with debugging Passenger instances that looks interesting, but the documentation is lacking:
http://github.com/ddollar/socket-debugger/tree/master
I had a ruby process related to Phusion Passenger, which consumed lots of CPU, even though it should have been idle.
The problem went away after I ran
date -s "`date`"
as suggested in this thread. (That was on Debian Squeeze)
Apparently, the problem was related to a leap second, and could affect many other applications like MySQL, Java, etc. More info in this thread on lklm.
We saw something similar to this with very long running SQL queries.
MySQL would kill the queries because they exceeded the long running limit and the thread never realized that the query was dead.
You may want to check the database logs.
This is a recurring issue with passenger. I've seen this problem many times helping people that ran ruby on rails with passenger. I don't have a fix but you might want to try this http://www.modrails.com/documentation/Users%20guide%20Apache.html#debugging_frozen

Resources