We’ve had a number of users getting going with our Rails-all-in-one server template and from the questions we’ve received it’s clearly time to cover some more advanced topics.
The template does include automatic database backups but you need to provide the necessary information to enable them. Edit the template before launching the server and fill in the
DB_SCHEMA_NAME variables as shown in the screen shot below (ignore the
The mysql dumps will be stored in the bucket you name with a filename consisting of the prefix and the date/time. In my example, it would be something like
test-dump-200710081047.gz in the
Additions to the server template
If you want to add additional functionality to the template, such as installing a cron job that does some daily back-end processing, you can clone the server template and add your own RightScript that installs and configures that functionality. If you parametrize your RightScript you can plug it into other server templates in the future. Let’s walk through an example. First let’s create a RightScript: go to the Design > RightScripts menu entry, hit the New RightScript button and enter something like this:
Note that I used an all-caps variable
APPLICATION_LOG_DIR in the script and hit the Identify button to locate such all-caps variables and flag them as input parameters to the script. This will allow me to set the parameter when I launch the server. The way these parameters work is that the value is passed into an environment variable when the script is run. (This example script is not tested and I just notice that a
chmod +x of the script is needed for sure…)
Now we can insert this RightScript into the server template, but first we need to clone the server template so we can modify our copy (note that the security group and ssh keys have to be entered into the template before it can be cloned, see step 2):
Now add the script to the template’s boot sequence:
Many folks are starting to use ImageScience to resize uploaded images and that requires FreeImage. How do you install all that? You can download FreeImage, compile it, create an RPM, and then write a RightScript that installs the RPM, or you could just ask us… Go to the server template that needs ImageScience, clone it if you haven’t done so already, and then add our FreeImage installation RightScript to the boot sequence as follows:
You should then move the script into the middle of the boot sequence:
You also need to install the ImageScience gem:
Add the “RB custom gems install v1” RightScript after the FreeImage RightScript and put “image_science” into the resulting OPT_GEMS_LIST variable in the server template (this RightScript might already be in your server template).
How to make DNS work
Now that you have customized your server template you can launch your server, but for people to find your site you obviously need to point DNS at it. The short answer is that you can do this manually or automatically. To do it manually, once your server is operational, you need to find out what it’s IP address is. You can locate the public hostname on the RightScale web site and enter it into your favorite DNS service. To automate this, we wrote a RightScript that does a wget or curl request to the DNS service we use (DNSmadeeasy.com) to set the IP address. To implement something similar you can locate the public IP address in
/var/spool/ec2/meta-data.sh, the easiest is to simply source that file in a shell RightScript. To make all this a bit easier we’ll publish our DNS RightScript for DNSmadeeasy.com shortly.
More questions? Please don’t hesitate to post a comment here or to send us email at email@example.com