What Warehouse commands are available?Post to delicious
Warehouse has a collection of commands that can be run from the console to perform various administrative tasks. All commands take a RAILS_ENV parameter to specify which rails environment is used. If you don't want to specify 'production' on all of them, you can just use the same database connection options for production and development if you like.
Bootstrap
Run rake warehouse:bootstrap to prepare it for installation. It checks for a few prerequisites such as the ruby/subversion bindings and loads the Database schema. This will clear your database, so don't run it again unless you want to reset your installation.
Post Commit Hook
Warehouse relies on a Subversion post-commit hook to keep itself updated. The rake warehouse:post_commit task takes these options:
- Add RAILS_ENV=production to force the rails production environment
- REPO_PATH is given by Subversion, and will be a full path to your repository.
- REPO specifies, by subdomain, which repository is being updated. If REPO_PATH ends in the repository subdomain, such as
/var/repos/lighthouse, then this option can be omitted. - CHANGESET specifies the new changeset of this repository.
Currently, all this does is synchronizes the changeset for you. However, this is the future entry point into custom post-commit tasks, such as email notification, Lighthouse updates, etc. Here's what a sample post-commit hook could look like:
#!/bin/sh
cd /path/to/warehouse
rake warehouse:post_commit RAILS_ENV=production REPO_PATH=$1 REVISION=$2
Synchronize your Changesets
Warehouse uses rake warehouse:sync to seed the database from subversion changesets. You can do this from the Warehouse installation screen, as well as the repository admin, but running from the console is much faster. It accepts some options:
- By default, runs on all repositories. These three options can be supplied together and in any order you wish.
- Add RAILS_ENV=production to force the rails production environment:
rake warehouse:sync RAILS_ENV=production - Add REPO=repo-subdomain to specify a single repository:
rake warehouse:sync REPO=warehouse - Add NUM=# to specify how many changesets to add. By default, the task will attempt to sync the remaining changesets. For a new repository with a lot of history, this can a few minutes. However, you can limit the number of changesets and complete the sync in smaller steps.
rake warehouse:sync NUM=100
Clear your Changesets
Run rake warehouse:clear to clear the changesets from the Warehouse database and start over. This takes the same options as warehouse:sync, except that NUM is ignored.
Build SVN Access Configuration File
Warehouse can build your svn configuration files for you with rake warehouse:build_config. Naturally, you won't want to keep running this command when you update a repository's access, so you can add this command to the permissions text field in the Admin Settings.
- RAILS_ENV specifies which rails environment to use. This should be production.
- CONFIG specifies where to save the file. By default, it will write to config/svn.conf from your Warehouse application directory.
- REPO specifies which repository to build the configuration file for. By default, it adds lines for all repositories.
rake warehouse:build_config RAILS_ENV=production CONFIG=/var/repos/warehouse/access.conf REPO=warehouse
Import Users
Warehouse can import users and passwords from an existing htpasswd file (used by svnserve and Apache for authenticating subversion repositories). By default, it assumes passwords are using CRYPT encryption, which is what htpasswd uses by default.
- RAILS_ENV specifies which rails environment to use. This should be production.
- CONFIG specifies the path to the htpasswd file.
- If you add REPO, you can automatically grant the imported users access to the given repository.
- EMAIL sets the desired email domain. Since htpasswd files don't store an email, this task guesses and uses login@EMAIL to build the email address.
- REPO_PATH specifies the path that the users are given access to.
- REPO_ACCESS should be set to 'rw' if they should have write access to the repository.
Import users into Warehouse:
rake warehouse:import_users CONFIG=/svn/repos/htpasswd.conf
Import users and grant them access to your repository:
rake warehouse:import_users CONFIG=/svn/repos/htpasswd.conf REPO=lighthouse
Import users and grant them read/write access to a a subdirectory:
rake warehouse:import_users CONFIG=/svn/repos/htpasswd.conf REPO=lighthouse REPO_PATH=/website REPO_ACCESS=rw
Write htpasswd File
Run rake warehouse:build_htpasswd to build a single htpasswd file for all Warehouse members.
- RAILS_ENV specifies which rails environment to use. This should be production.
- CONFIG specifies the path to the written htpasswd file, defaulting to 'config/htpasswd.conf'
Write htpasswd File For a Specific Repository
Run rake warehouse:build_repo_htpasswd to build a single htpasswd file for the members of a given repository. This takes one additional option to the warehouse:build_htpasswd command.
- REPO specifies the repository by subdomain.
Write htpasswd File for a Member's Repositories
Run rake warehouse:build_user_htpasswd to build htpasswd files for all the repositories the given user has access to. This command is designed for use with the password command option in the Admin Settings. This also takes one additional option to the warehouse:build_htpasswd command.
- USER specifies the user by its ID.
Since this writes multiple files, the CONFIG requires a special :repo variable. This command will write these files (assuming this user has access to the Lighthouse and Warehouse repositories): config/lighthouse/htpasswd.conf and config/warehouse/htpasswd.conf:
rake warehouse:build_user_htpasswd CONFIG=config/:repo/htpasswd.conf USER=5
Setup Deployment Layout
Run rake warehouse:setup to create a recommended deployment layout for Warehouse. This isn't required, but it can make things easier on you when it comes time to upgrade. Running this will store the current release in warehouse/releases, shared files in warehouse/shared, and create a symlink to this version in warehouse/current. From here, you can point your web server configuration settings to the constant warehouse/current path. For more info on setting something like this up manually, check the Warehouse upgrading FAQ entry.
Upgrading Warehouse
Use rake warehouse:upgrade to reset the 'current' symlink and transition your shared files over. Once this is done, be sure to restart the Warehouse rails application.
« Can I Manage Multiple Repositories? | FAQs | What are these Admin Settings for? »
Talk To Me Now!
If you've got an IRC client, you can join us in #activereload on irc.freenode.net. We'll talk about ninjas, code, gaming and more ninjas.
—Robert Bousquet, New LeadersWith all those cooks in the kitchen at the same time while launching our latest project, Warehouse helped us keep tabs on everything!

