Site5 Community Forums
|
|
|||||||
| Ruby Discussion of Ruby and all related code, and its usage and development, both on Site5 servers and elsewhere |
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi all--
i want to share my experiences getting ruby on rails deployed to site5, since it appears there aren't that many details about some of the finer points. here's what i assume (since these were my needs): a) you have a rails development setup on your local box b) you want to deploy to your site5 shared account c) you want a subversion repository on the site5 account to manage your files d) you want to use switchtower to deploy your application here are some of my notes from getting this working: - get subversion working on your local box. you really only need to use the client from this end. visit http://subversion.tigris.org if you're new to subversion. {BEGIN WINDOWS INTERLUDE} - i (have to) use a windows box at work, so i had to do some more things to get ssh and subversion working from a command line. i use cygwin to get more unix-y tools, including a command-line ssh client (note: i do use the windows-native installer of subversion because i've found that easier). see http://www.cygwin.com/ if you're not familiar. basically, i had to setup the subversion client to use my cygwin's ssh.exe for communicating with the remote server. there's a config file in: Code:
C:\Documents and Settings\{user}\Application Data\Subversion\config
Code:
ssh = $SVN_SSH C:\\tools\\cygwin\\bin\\ssh.exe there are also ways to do this using the PuTTy suite. see http://www.chiark.greenend.org.uk/~sgtatham/putty/ now you should be able to do things like run the svn command line client or use TortoiseSVN from the Explorer, and connect to repositories on your Site5 account using svn+ssh -style URLs (once you get a few other things set up) - on anoter note, windows users will have to set the execute and eof-style properties for several files in a rails project. this is a fairly intermediate-to-advanced subversion task that's ez if you just read the subversion book at http://svnbook.red-bean.com/ you need to set these properties on all the files in the script/ folder, as well as public/.htaccess and public/dispatch.*. from the script folder, you can execute Code:
svn propset svn:executable ON -R . svn propset svn:eol-style NATIVE -R . {WINDOWS INTERLUDE OVER} - meanwhile, back at the ranch, open a ticket with support to get Bash enabled as your login shell in order to begin setting up subversion, and once you've logged in at least once to agree to the banner, ask to have the banner removed. Otherwise you'll have problems with some fancy ssh work later on. - once ssh'ed into your account with bash (prompt will be something like "-bash-3.00$"), create your subversion repository. i did this at /home/{myaccount}/repos/. if you don't know how to do this, you can learn more about subversion by visiting http://subversion.tigris.org - setup an RSA key pair to login using SSH without entering the password a bunch of times. this is useful for using subversion and switchtower since they sometimes SSH into the machine several times. i generated a public key on my local box using ssh-keygen, and then put my public key onto the site5 server at ~/.ssh/authorized_keys using the scp program, which lets you remotely copy files to a server. a good tutorial that includes information on doing the RSA key thing: http://berserk.org/2005/10/08/textma...ng-workaround/ note that some of this tutorial may not apply to what you're doing here! just pay attention to the parts about getting SSH working. - at this point you should be able to test svn from your local command line as follows: Code:
svn list svn+ssh://{username}@{domain or ip}/home/{username}/repos/
![]() note: you may need to change this up in your case if you're not just pointing to the ip address of your sit5 host (like i am, since i haven't gotten this whole thing stable enough yet to move our company's domain over!) - now switchtower will pretty much work out of the box, as far as i've seen. if you're not familiar, the book is up at: http://manuals.rubyonrails.com/read/book/17 i created a folder on my site called /home/{user}/apps to store my rails application code. a few things that you need to set in your deploy.rb file. note you will need to sustitute in your username (unless it's 'jd'): Code:
set :repository, "file:///home/jd/repos/#{application}/trunk"
...
set :deploy_to, "/home/jd/apps/#{application}"
set :user, "jd"
...
desc "Restart the web server. Overrides the default task for Site5 use"
task :restart, :roles => :app do
# reaper script doesn't check the user of the fcgi instances, so this will
# try to send a 'kill -USR2' restart message to EVERY found dispatch.fcgi.
send(restart_via, "#{current_path}/script/process/reaper -d 'dispatch.fcgi'")
end
- once all that was in place, i was able to do this: Code:
rake remote_exec ACTION=setup Code:
rake deploy note:i link my site5 public_html folder to my rails public folder. from your home folder on site5: Code:
ln -s /home/{username}/apps/site/curent/public public_html
- getting FCGI working: i changed my .htaccess to point to .fcgi instead of .cgi. i do this on my local copy, so the change shows up when switchtower checks the app out on the site5 server. it's no bother to me since i develop under WEBrick, which ignores this anyway. ditto to the workaround to setting rails into production mode by uncommenting the first statement in the environment.rb file. it doesn't really bother me locally to test with this left in, and once i've deployed to the server the application works in production mode by default. - however, when you're doing this, you will have to kill your dispatch.fcgi instances whenever you wish to re-deploy your application to the server (since we changed the restart task to be a no-op). anyone know of a good way to restart the .fcgi instances that can be executed by the restart task? i'm sure i've glossed over some things, but jeez i hope this long-winded post helps somebody. at the very least i can look myself up when i need to do this next ![]() jd northrup visionwise, inc Last edited by jdnorthrup; January 9th, 2006 at 04:20 PM. |
|
#2
|
|||
|
|||
|
JD, thanks. I've stuck this thread so others can find it easier.
__________________
-Steven Site5 Forum Overseer Want the answers to the universe and everything? Check out the Site5 Wiki! "To err is human, to forgive divine." |
|
#3
|
|||
|
|||
|
SwitchTower on OS X
Just as an addendum to this, if you are on OS X, then you need to install a working copy of Ruby in order for SwitchTower to work properly (the default that comes with OS X has a problem with OpenSSL apparently).
See this page for more information. David |
|
#4
|
|||
|
|||
|
Awesome, just what I needed. Thanks!!
|
|
#5
|
||||
|
||||
|
Subclipse and Subversion svn+ssh://
Another addendum
If you want to use Subclipse 0.9.105 (an Eclipse Extension) to manage your subversion repository you are interested on this post. jyap created a wiki with some information about "Subversion on Site5". It will be good to look at: http://www.julianyap.com/wiki/index....rsion_on_Site5 Check that it is running properly: Quote:
Select "Search for new features to install" and Click "Next ->" Click "New Remote Site..." and type: Code:
Name: "Subclipse" URL: http://subclipse.tigris.org/update It will check for the latest update. Select the version you want to install and OK. After a while and the Workbench has restarted click Window -> Show View -> Other And select "SVN Repository" This will change the perspective of Eclipse to the SVN Perspective. Change the properties of SVN to JavaSVN Window -> Preferences... +Team +SVN and select "JavaSVN (Pure Java)" Click OK Now, right click on the "SVN Repository" panel and "New" -> Repository Location The URL is Code:
svn+ssh://{domain or ip}/home/{username}/repos/
It will ask you the username and password. Click Ok and that is all ![]() I ignore how to show the svn directory on the web. If anyone knows, it will be very useful to add a post ![]() If you are interested or want more information please check http://subclipse.tigris.org/servlets...ers&msgNo=3334 Last edited by rath; January 25th, 2006 at 02:13 AM. |
|
#6
|
|||
|
|||
|
Thanks for the great walk-through. I'm having problems in the "rake deploy" section.
When I issue Code:
rake deploy Code:
querying latest revision...
c:/ruby/bin/rake: No such file or directory - svn log -q -rhead svn+ssh://{domain}/home/{username}/{path-to-repository}/trunk
Code:
-bash-3.00$ svn log -q -rhead svn+ssh://{domain}/home/{username}/{path-to-repository}/trunk
svn: Permission denied
Thanks! Edit: I should say that I can checkout the repository in question to my local machine via TortoiseSVN using the same URL... Last edited by motorizedflowers; January 27th, 2006 at 03:57 PM. |
|
#7
|
|||
|
|||
|
Quote:
On your shell account, I'd say that you need to pass a username and password to the svn command? What do your settings in Tortoise for the repository say? |
|
#8
|
|||
|
|||
|
yes, from your windows command line, if you type "svn -h" do you get the help listing?
the second problem is if you're on the site5 server via ssh, you use the file:/// sytax to access your repository, not the svn+ssh. if you're already there, there's no need to tunnel in! eg: Code:
-bash-3.00$ svn list file:///home/jd/repos/{application}/trunk
hope that helps, jd |
|
#9
|
|||
|
|||
|
Using differents repo from my local box and site5
jd,
I got problems running switchtower 0.10.0 when I try to run "rake deploy" from my local box (windows) If I set the repository to (deploy.rb): set :repository, "file:///home/[my_user]/repo/[my_app]/trunk" My local box (windows) can't reach the subversion repository located in site5 If I set the repository to: set :repository, "svn+ssh://[my_user]@[my_site]/home/[my_user]/repo/[my_app]/trunk/" I got a "permission denied" when svn run in site5. How do you deal with this? The workaround I found was: 1. Leave the :repository property in deploy.rb to file:// syntax. set :repository, "file:///home/[my_user]/repo/[my_app]/trunk" 2.Define a new property :repository_from_dev in deploy.rb to svn+ssh:// syntax set :repository_from_dev, "svn+ssh://[my_user]@[my_site]/home/[my_user]/repo/[my_app]/trunk/" 3. Modify the lib/tasks/switchtower.rake file in order to change the switchtower behavior, adding this line: # ================================================== ===== # Extension to deploy to site5 # ================================================== ===== require 'switchtower/scm/subversion' module SwitchTower module SCM class Subversion def latest_revision configuration.logger.debug "querying latest revision..." unless @latest_revision #repo = configuration.repository repo = configuration.repository_from_dev puts "usando repository_from_dev: #{repo}" until @latest_revision match = svn_log(repo).scan(/r(\d+)/).first @latest_revision = match ? match.first : nil if @latest_revision.nil? # if a revision number was not reported, move up a level in the path # and try again. repo = File.dirname(repo) end end @latest_revision end end end end Now "rake deploy" works fine Any suggestions? maybe another approach? |
|
#10
|
|||
|
|||
|
Quote:
Quote:
So now switchtower can connect to site5 and my repository, (after giving me local errors for the file:/// syntax), but when it runs the ":restart" task above, it runs it sudo, which is unnecessary, and which I don't have permissions for anyway. How can I get rid of the sudo? Thanks for all your help! Last edited by motorizedflowers; January 28th, 2006 at 11:20 AM. |
|
#11
|
|||
|
|||
|
Quote:
Code:
task :restart, :roles => :app do run "killall -9 dispatch.fcgi" end David |
|
#12
|
|||
|
|||
|
David,
Thanks for that tip. Doing the "kill" gave me errors in the rake-ing (even though I think it worked), so I combined your task with jd's like so: Code:
desc "Restart the web server. Overrides the default task for Site5 use"
task :restart, :roles => :app do
run "#{current_path}/script/process/reaper -d 'dispatch.fcgi'"
end
Another note, in case it helps anyone...in order to make the reaper script executable, I had to issue Code:
svn propset svn:executable ON scripts/process/* |
|
#13
|
|||
|
|||
|
Here is a very helpful post that I think makes the process of creating your first RoR app and deploying it, very easy: http://forums.asmallorange.com/index...75&#entry26875
|
|
#14
|
|||
|
|||
|
When I tried reset as mentioned here I get the following message. Any ideas
executing "sudo /home/uid/apps/app/current/script/process/reaper -d 'dispatch.fcgi'" processing command [www.mydomain.com] executing command [out :: www.mydomain.com] UID is not in the sudoers file. This incident will be reported. command finished rake aborted! command "sudo /home/uid/apps/itrademall/current/script/process/reaper -d 'd ispatch.fcgi'" failed on www.mydomain.com |
|
#15
|
|||
|
|||
|
Quote:
Code:
killall -9 dispatch.fcgi Cheers, David |
|
#16
|
|||
|
|||
|
I'm having problems getting the scp command to work right when copying my public key from the local machine to my site5 account.
If I enter: % scp .ssh/id_rsa.pub username@remote_host:.ssh/ I get a "no such file or directory error" on the remote host. Any help would be appreciated. jw |
|
#17
|
|||
|
|||
|
svn:ignore *.log
I started playing with SVN for the first time this weekend and I love it.
How do you keep svn from trying to keep the log files in the repository? I am using tortoiseSVN and RadRails. When ever I run webrick, it updates the log files, then on my next commit, it always tries to add the development.log. I added the property svn:ignore *.log to the log folder, but that doesn't seem to help. ![]() Keeping log files under version control seem like a waste of space. [Edit] Stupid me, I just realized if I delete the log files from the repo, they will no longer be under version control. Last edited by scottnj; February 6th, 2006 at 05:56 PM. |
|
#18
|
|||
|
|||
|
Strangeglow,
I'd try copying to the directory /home/[username]/.ssh/ See if that works... |
|
#19
|
|||
|
|||
|
Quote:
|
|
#20
|
|||
|
|||
|
You should be able to create that directory like any other directory.
__________________
-Steven Site5 Forum Overseer Want the answers to the universe and everything? Check out the Site5 Wiki! "To err is human, to forgive divine." |


how to show the svn directory on the web. If anyone knows, it will be very useful to add a post 
