Integrity CI Server not running builds when using Passenger / Apache webserver - ruby-on-rails

The Integrity App is working fine for me in my OSX dev environment. I've deployed an instance to a Ubuntu server for my production setup, and I'm able to setup a new project. Once I call a manual build to attempt to test a first build the build record is created, but the build is never run.
I've added a bunch of logging to my application and have been able to track the point of failure to when the build job is added in ThreadPool#add It appears everything is running fine to get the job added to the build pool, but that the pool isn't actually running anything despite being spawned and no exceptions being raised.
The environment I'm running is Ubuntu 11.04, RVM & Ruby 1.9.2-p290, Passenger / Apache, and running Integrity from master w/Sqlite3 and ThreadedBuilder.
UPDATE:
I found an article indicating this may be an issue with using Apache & Passenger not loading the Ruby environment properly. This appears to be the case since in dev I'm just running bundle exec rackup, and in production I was trying to use Passenger. So on the production machine I started an instance of Integrity using bundle exec rackup, which does indeed actually start running the builds except that it didn't properly find the bundler gem as it should have. I'm sure I can track down a fix for that somehow.
So essentially the issue I am having is with running Integrity with Passenger rather than using rackup. The article that pointed me in this direction didn't work with their solution of getting Ruby in the Apache environment though. Can anyone help me determine how to properly run Integrity with Passenger?

The issue was in the way Passenger handles threading. By changing to the DelayedBuilder using DelayedJob for builds rather than the ThreadedBuilder I was able to use Passenger as the web server.

Related

Redmine rails app code changes not reflected - had to restart nginx every time

I'm trying to customize the redmine app which is built on top of rails. I set up a Vagrant with nginx + passenger. When I modify the code (say, app/controllers/issues_controller.rb), the changes are not picked by web/app server. The changes are reflected only when I restart the web server.
I have virtually tried every solution available with googling.
Ensure the app is running development mode. tried both rails_env directive RAILS_ENV in config/environment.rb
caching is disabled
First, I thought it could be the vagrant bug so I set up the same in Digital Ocean server, changed the code, still the same.
I suspect only these but I don't know how to validate it.
Nginx + passenger continues to run in development mode even after changing the environment so my changes not picked up immediately.
There might be something special to redmine app that changes inside app directory is not picked up until web server restart.
I fixed it myself by upgrading from Redmine 3.4.2 to 3.4.4. Redmine has a pertaining to Unloadable plugin convention (https://www.redmine.org/issues/20513) which appears to have been fixed in latest version. Now, I'm able to make code changes and see the results immediately in the browser.

What, where and how to upload Ruby on Rails application files to the VPS?

I am using Ruby on Rails 3.0.9 and I would like to publish my web site. I already set my VPS running Ubuntu 10.04 LTS and the capistrano gem (this one I think as well as possible). Now, what I need to do is to upload all files to the www/project_name directory (I am on Mac OS)...
What I have to do to accomplish that?
You don't need your deployment machine to have Capistrano. Capistrano automates a bunch of tasks that I suggest you do at least one manually so you know what's going on. Sooner or later, you'll be debugging some Capistrano task, so you may as well figure out the guts sooner or later.
Coarsely, what you need to do is to basically duplicate your development environment on your production machine. If you have it on version control, you can git clone or svn whateveritis on your production machine. If not, you can scp it over with scp /local/rails/dir remoteuser#remotehost:www/projectname.
At this point, you should actually do the remainder of the work on the server. Since you've managed to install Capistrano, I assume you're familiar with the basics of making your way around SSH.
Once the code's over, you have to install the prerequisites. If you're using 3.0.9 you should be able to run bundle install --deployment, where the deployment flag basically tells bundler to use the identical gem set as on your development machine.
When that's done, actually getting the server online will vary based on your setup. If you're using non-standalone passenger, just follow any of the many guides at this point. If you're running standalone passenger or thin or unicorn or any other standalone rails server, go ahead and start that in daemon mode (so it won't quit on you when you end your SSH session) and make sure you se the production flag. You can either start it in sudo and have it listen on port 80 (e.g., sudo thin start -d -p 80) or have it listen on a higher-number port and use a reverse proxy on your WWW-facing server. The instructions for how to reverse proxy are all over the internet.
Let me know if you have any questions.
You have half of a deployment solution with Capistrano. Commonly Passenger is used as the other half, which sits on the server and loads your app. To accomplish this, usually, SSH keys are used. There are numerous tutorials on how to set this up. One of my favorites written by Dan Benjamin can be found on his blog Hivelogic.
Edited to provide more begginer info:
Capistrano begginer's guide from the Capistrano wiki.
Passenger Stand Alone Guide from the Passenger website.
Be sure to check out the other guides for the webserver of your choice when you're ready.
These guides will give you the background you need to get a local Passenger & Capistrano deployment going. These guides provide the knowledge you need to get achieve what you want.
Simple and short sample of deployment via SSH http://alexeypetrushin.github.com/vfs/ssh_deployment.html

Restarting Rails Application

I am building an application that will only be run on a local network and am looking for the best way to restart my server from within the application itself. For the time being this is only running on Windows using WEBrick.
Look at Capistrano as others have suggested, it's fantastic :)
$ cap deploy
That's all you have to do. It'll grab the latest source from your git/SVN repo (lots more supported ofc), deploy, and restart your app server.

How do I published a Ruby on Rails application online?

I have a simple Ruby on Rails application that works through a localhost test (both using sqlite, or ruby mysql2 gem).
I have a web server ready to upload my app online.
I understand that I need to create a new mysql database, which is no problem, and obviously add the connect info in the database.yml, but how do I propertly upload the whole thing (app root) to a public dir of my site?
Rails itself contains a few links to get you started with deployment. I was in your boat a while ago, and I got started with Passenger and Apache within half an hour (although I did have some light Apache experience going in).
Get started just to prove to yourself you can do it
Not that it's a good idea, but the balls to the wall easiest way to "deploy" is the following (assuming you've already pulled your application into your deployment environment, created your database, and run rake db:migrate and any application-specific steps like bundle install on Rails 3):
rails server -p 80 on Rails 3 (./script/server -p 80 on Rails 2).
There is no step 2.
This has to be run on a machine for which you have administrative rights and for which port 80 is not already being listened to by another application. This is suboptimal in many ways, most apparent of which is that it won't allow for virtual hosting (i.e., it won't cooperate with other "websites" being run from that server), but it's a good baby step to dip your feet into.
Go to the machine's FQDN or in fact any hostname that resolves to the machine's IP address (via a hosts file or an A record), and you'll see your application.
Now do it properly
You're going to want to do the following to bring your application "up to speed":
Deploy it behind a virtual host behind a webserver application like Apache
Use a production-oriented deployment setup (WEBrick's single-threadedness, among other factors, make it unsuitable for production)
Actually use the "production" rails environment
I'll be recommending a very, very typical Apache/Passenger deployment environment. The reason is that (at least it seems to me) this particular stack is the most thoroughly supported across the Internet, so if you need to get help, you'll have the easiest time with this.
1. Set up Apache
I don't want to sound like a tool, but setting up Apache (if it's not already set up on your deployment environment) is left as an exercise for the reader. It also varies enough across platforms that I couldn't possible write a catchall guide. Coarsely, use your distribution's package manager (for Ubuntu, this is apt-get) to get it hooked up.
2. Set up Passenger
Passenger installation is even easier. You just run one command, and their guide runs you through all the steps. At this point, in your Rails application root, you'll be able to run passenger start instead of rails s to have Passenger fill the role that WEBrick once did.
3. Hook up Passenger with Apache
The Passenger guide fairly thoroughly documents, step by step, how to set it all up. The ServerName attribute in Apache's VirtualHost entry should be set to your hostname. Passenger will "find" the Rails application from the public directory you give Apache, and when you restart Apache, the first time the server gets a request for a page, Passenger will hook up your Rails application and start serving up files.
I'm not performing these steps as I'm writing this guide, so I'm not sure to what extent this is done automatically, but make sure that the site is enabled via a2ensite (in the case that you're putting this VirtualHost node in the sites-available directory) and that Passenger is enabled via a2enmod.
Make sure your production environment is ready
This is likely to be the first time you're using the production environment. Most rake tasks don't automatically act on the production environment, but you can conveniently force them to by including RAILS_ENV=production inline with any rake tasks. The one you'll very likely be running is rake db:migrate RAILS_ENV=production. The bundler in Rails 3 works independently of environment.
5. Go
Restart Apache. The specifics on how to do this will vary by distribution, so you'll have to look it up. For Ubuntu, apache2ctl restart does it for me.
Visit your hostname as you defined in ServerName, and you should be seeing your application up and running.
I've heard gems like capistrano can assist with this.
https://github.com/capistrano/capistrano
Heroku is an excellent (free) option: http://docs.heroku.com/quickstart
Also, deploying to Heroku is as easy as it gets!

Getting rails application from github to debian server

I've been developing my first rails application on my windows computer.
But now i have been setting up a debian server with nginx and passanger.
I've been using Github to keep track of my application and now i am wondering how i can get the Github version of my application to the debian server and put it in production mode?
Anybody that have a good guide about this or something?
Getting the code to your production server is just the tip of the iceberg. What if you want to rollback to the previous version? Or tag a specific version and deploy it? How will you deal with different versions of configuration files for your development vs. production scenarios?
That's why you need Capistrano. It lets you do all this (and more) from the command line of your development machine. Take a look at the "From the Beginning" chapter to get started.
You'll also need some basic knowledge of shell commands and SSH.
Also have a look at the Phusion Passenger docs to see what is needed on the server side.

Resources