Can a Heroku app interface with Amazon EC2 instances - ruby-on-rails

I am toying around with building a rails app in the near future and using Heroku to host it, but the app will need to interact with EC2 instances through SSH (unless I can find a better way). I probably could build a pseudo API...but direct console access would be easier. I am going to need the following:
1) Run commands on the EC2 console
2) Read the results
3) dynamically start and stop ec2 instances (a little unrelated but I am curious if heroku can do this)
I know heroku hosts their infrastructure on EC2, so latency would be grean and it would probably be more straight forward to just host my own rails server on an EC2 instance, but I really like the automation and tools available within Heroku.

EC2 specific: http://rubygems.org/gems/amazon-ec2
Console Commands/Results: http://rubygems.org/gems/net-ssh
Both these Gems should address my issue. Thanks Zabba for the ec2 gem. I am a little new to rails, and should have started looking there. I love how easy it is to install new functionality into the language.

Related

Can I keep my database on my local network but deploy my rails app on a hosting service?

I have a rails application that is currently hosted on Heroku. It is used on our local network only, and my boss does not want a 3rd party hosting our data. I convinced IT to set me up a virtual windows server to deploy my app on. However, it has been very difficult to set up for production.
Is there anyway that I can use a hosting service for my application, but have the database reside on our local network?
Or is there an easier way to deploy a rails app on a windows server? I have been looking into using the Linux Subsystem for Windows.
If your app is used on your local network only, why not ditch Heroku and host your Rails app locally as well? What benefit is a scalable cloud hosting provider giving you? Especially since it seems your boss has security concerns about remote hosting of a database. Bringing the entire thing in house may be the best solution.
Simple answer is yes you can, but why would you. It's simpler to run your application locally than connecting your remote app to a local database.
Your best bet is to use a Linux virtual machine instead of Windows, usually there is to much hassle to get rails application to work on windows, especially compiling native gems.
I suggest that you get a CentOS VM, and install Nginx with passenger gem using rbenv or rvm.
Digital Ocean has a nice guide that explains this process in details:
How To Deploy Rails Apps Using Passenger With Nginx on CentOS 6.5

Rails: How to "publish" a website

So, I am almost done with my website. I created it using ruby on rails on the Cloud9 IDE. Is there a way to publish it? To go on it, a user has to be signed on Cloud9 and then I need to run the code on the terminal...
rails server -b $IP -p $PORT
How would I be able to publish my website? I am very new to rails and I have no idea.
To publish your website you need to host it somewhere.
There are multiple ways to do this. For instance you can use Heroku. They provide PaaS (Platform as a service), which means they will handle the installation of the app for you and the maintenance of the virtual machine it resides (updates and whatnot).
Heroku also gives you a very nice admin view for the status of your app, online log display and some other goodies.
Another alternative would be Amazon Web Services, DigitalOcean or Linode (among many others!). They provide IaaS(Infrastructure as a Service). They only give you a virtual machine with your choice of operating system, you will have to manually publish your app and provide manual maintenance of the VM and pretty much anything including the database itself.
Using Heroku would be your best choice for the moment as they are very straightforward with the publishing part. Once you get the grip you can go to the other platforms for customization.
You will also need some deployment tools such as capistrano or mina.
If you're going to host your app in heroku, it's much easier to deploy. As simple as pushing your codes with git.

deploying a rails project to a remote server

is it possible to deploy a rails project to a remote server using FileZilla ? the server is running nginx/1.4.6 (ubuntu)
if no what is the best way to deploy the project if there is already a running version !
To answer your question yes, the code needs to be up, so FTP should do the trick. You might need to restart nginx to pick up the changes, usually touching a restart.txt is enough, but that's particular to your setup.
Is this the best way? Possibly not!
Others suggested capistrano and that would be a good fit for a server you maintain, or go Heroku (or similar) service for a simpler setup.
Deploying a Rails app is a tough job. There is always the easy way (heroku) however shared servers don't deal well with rails. Theoretically you can but usually this shared servers have really outdated ruby and rails versions and are absolutely useless. And you can try to connect via ssh and try to update it but i doubt you will be able to do that. So... If you are a rails developer i can suggest.
1- For small apps run Heroku (easy and free) however cost grows like hell with the app's growth
2- If you're thinking about developing big apps get a dedicated server (you can get cheap ones for 5€/month) and configure it as u would for your computer except when you run rails you run it in production.
3- Trust me... i fought enough Rails and shared servers and i quit... I just gave up

How to create a VM that mirrors the RoR production version

I am working on an open source project and there is an issue where an upload error only seems to occur on the production side that is running apache and unicorn.
Due to privacy issues and risks, I am unable to mess around in the actual production side (such as creating a temp id for myself with various privileges.
Is there anyway that I can quickly create a VM with such setup in my own computer that would mirror the live site?
The site is running in RoR 4, latest unicorn, and latest stable version of apache.
There are a couple of ways you can be able to accomplish this. You can use vagrant and also with the rising popularity of Docker containers, you can easily model production environment on your computer. Since you indicated a faster way to get the VM up and running, I would recommend using railsbox.io. Its amazing and it saves you a lot of time. According to their webiste -
Fast and easy Ruby on Rails virtual machines. Streamline your
development workflow in no time by creating production-like virtual
machine with your development environment. Try this extremely simple
to use VM configuration tool to create new Ruby on Rails server using
vagrant and ansible.
The app helps you setup a VM with ease.

Is there a linode version of EC2 on Rails?

We really like the idea of hosting with Amazon EC2 and the excellent EC2 on Rails, but our cashflow isn't enough to justify a move to EC2. So we've decided to host with linode. Now we're trying to put together the best Rails server build.
For those that don't know, EC2 on Rails is an opinionated Ubuntu Linux Server image for Amazon's EC2 hosting service. Out of the box, it runs a standard Ruby on Rails application with little to no customization.
So, is there something like EC2 on Rails for linode?
We'd need at least the following:
Ruby 1.8.7
Ruby on Rails 2.3.8
MySQL 5
memcached
Automatically runs hourly, daily, weekly and monthly scripts if they exist in Rails application’s script directory
Local Postfix SMTP mail server
SSL support
Passenger + Ngnix or Mongrel + Apache
32 bit image Ubuntu
With a railsy setup, meaning fast and simple. So, anyone run across anything like EC2 on Rails, but for linode?
I have been using linode for my personal use for a while and I think no matter what, you are probably going to have to get your hands dirty. I kind of like it for exactly that reason, but that is just my taste. They do have stack scripts with some predefined setups. The closest I can find to what you are looking for is a ruby/apache/mysql script that is fairly customizable.
From the script:
Installs a fully functioning, ready to
go stack that's optimized specifically
for your Linode's resources. By
default, it creates a VirtualHost
using the reverse DNS of your Linode's
primary IP.
This installs a stack based on Ruby,
Apache, and MySQL. This also gives you
the options to install gems so that
you can be up and running Ruby on
Rails in no time.
Optionally creates a MySQL database
and user, and assigns that user grants
to the database.
You may use this as an example for
creating more VirtualHosts. Set up
VirtualHosts, install your sites,
point your domains to your Linode, and
you're set!
This script downloads and compiles the
source from Ruby's ftp. Along with
Ruby, the latest version of ruby gems
is installed and you have a choice of
initial gems to install. Rails and
passenger can be used to have a ready
to go Rails server. Once this script
has finished be sure to run
'passenger-install-apache2-module' to
complete the passenger install.
Note that this script may take 1.5 - 2
hrs depending on the gems that are
specified.
All details of this stack script are
logged to /root/log.txt and the stack
script is finish when the line
"StackScript Finished!" is written to
the log file.
You might have good luck talking to their support though, they might have some more secret sauce that I haven't found yet.
Nothing in that setup sounds EC2-specific beyond the name. It appears it is just convenient to use with EC2, because they let you grab a disk image from another account.
You are welcome to create your own StackScript to do this and contribute it to the community. Once a StackScript is written, it can be marked public and used by others. EC2 on Rails has a public GitHub repository from which you can get started, and honestly, I'd love to see things like this ported to the StackScript system.

Resources