Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby redmine svn post-commit hook is extremally slow

I use the following post-commit hook for svn:

"path\to\ruby.exe" "path\to\redmine\script\runner" "Repository.fetch_changesets; Rails.logger.flush" -e production

It works correctly, but it takes about 1-2 minutes. I also thought that a lot of time is required for first commit, but successive commit takes the same amount of time.

Is it possible to improve such behavior?

I know about slow behavior of Ruby on Windows, about 3 times, but in my case it is much more longer.

Configuration is following: Windows Vista, redmine 1.1.1, Ruby 1.8.7 with RubyGems 1.8.7, all packages installed and testing is performed on the same PC.

like image 490
sergtk Avatar asked May 18 '26 09:05

sergtk


1 Answers

The problem is that script/runner starts up a new Rails process from scratch each time it's run, which will make your commit pause. So 3 commits == 3 startups and 3 shutdowns.

There are a few things you can do to improve this:

  1. Run the script/runner process in the background so it doesn't slow down your commit. On Linux you can do this by adding an & at the end of the command but I don't remember how to do it on Windows

  2. Instead of fetching changesets on each commit you can run it regularly through cron or a scheduled task. The rake task redmine:fetch_changesets is built for this purpose, it will iterate through each project and run fetch_changesets for you.

  3. The command you are running goes through every project and fetches the changes. If you know the project identifier you can change the query so it only gets the changes for the project you are working on:

    script\runner "Project.find('your-project').try(:repository).try(:fetch_changesets); Rails.logger.flush"

    Replace 'your-project' with the project identifier (found in most of the urls in Redmine). The try parts are used to make sure you don't get an empty record.

  4. Use the web service to fetch changesets instead of script/runner. The web service will use an existing Ruby process so it should already be loaded and the only slow down will be while Redmine downloads and processes the changes. This can also be used with the first option (i.e. background a web service request). Docs: http://www.redmine.org/projects/redmine/wiki/HowTo_setup_automatic_refresh_of_repositories_in_Redmine_on_commit

Personally, I just run a cronjob every hour (#2). Having the Repository view current isn't that important to me. Hope this gives you some ideas.

like image 109
Eric Davis Avatar answered May 19 '26 22:05

Eric Davis