1
Gitorious.org
2
=============
3
4
Contributing
5
============
6
7
Please see HACKING
8
9
License
10
=======
11
12
Please see the LICENSE file
13
14
15
Further documentation
16
=====================
17
Also see the files in the doc/ folder, they contain further detailed information
18
about setting up the application for specific linux distributions such as 
19
CentOS and Ubuntu/Debian
20
21
22
Installation to a production environment -- a partial walkthrough.
23
==================================================================
24
25
Make ready
26
==========
27
28
You may want to make separate directories, away from everything, to hold the
29
site code and the git repository respectively.  In production, you'll be setting
30
up a special user account too, but don't worry about that yet.
31
32
For this intro we're going to use, as examples,
33
34
* /www/gitorious           -- directory for the website code
35
* /gitorious/repositories  -- root directory for the git repositories
36
* a MySQL database on localhost at port 3306 with a _mysql_ user 'gitorious'
37
* eventually, a system account named 'gitslave'
38
39
All of these can be adjusted to suit: specifically, dirs within your home
40
directory are fine, and (though MySQL has the best development coverage), the
41
website code should be free of mysql-isms/quirks.
42
43
Prerequisites
44
=============
45
46
First of all, **we assume you have a working Ruby installation on your
47
machine**. While Gitorious may run fine on Ruby 1.9, you are likely to run
48
into encoding issues, and possibly other problems. Gitorious.org has reverted
49
its Ruby 1.9 setup to Ruby Enterprise Edition, which is the Ruby version we
50
recommend. If you don't want to run REE, we recommend stock 1.8.7.
51
52
Dependencies
53
============
54
55
First, install each of these Libraries/applications:
56
57
* Git                   (http://git-scm.org)
58
* Sphinx                (http://sphinxsearch.com/)
59
* MySQL                 (or whatever)
60
* ImageMagick           (need version >= 6.3.0)
61
* aspell (optional)
62
63
An ActiveMessaging (http://code.google.com/p/activemessaging/wiki/Installation) compatible queue
64
server. Gitorious.org runs ActiveMQ and STOMP, stompserver might be a nice
65
flyweight alternative for your needs
66
67
68
Getting the code
69
================
70
71
Next, get the gitorious code itself:
72
73
  # mkdir /www/gitorious ;# or another location of your choice
74
  # cd    /www/gitorious
75
  # git clone git://gitorious.org/gitorious/mainline.git gitorious
76
77
Now you need edit a couple of configuration files.
78
79
config/database.yml
80
------------------
81
82
This file contains settings for the databases used for Gitorious. The
83
Gitorious distribution provides a sample config file - database.sample.yml -
84
that you could copy to config/database.yml.
85
86
Gitorious should be database agnostic, so feel free to use your database of
87
choice. Gitorious.org uses MySQL, but there shouldn't be any MySQL specific
88
code in Gitorious, so use whatever you're most comfortable with.
89
90
config/gitorious.yml
91
--------------------
92
93
This file holds Gitorious specific configuration for each Rails environment.
94
There's a sample file in config/gitorious.sample.yml that describes what each
95
instruction means. Do make sure you have a section for each Rails environment,
96
especially if you're upgrading an existing Gitorious installation.
97
98
* Create a directory to hold project files
99
 
100
  # sudo mkdir  /gitorious/repositories
101
  
102
* Add the path to this directory under repository_base_path in gitorious.yml
103
* Make a long, complicated string. You can run "apg -m 64", or if you lack 'apg'
104
    `dd if=/dev/random count=1 | md5sum` ,
105
  and put that on the 'cookie_secret' line (replacing the 'ssssht').
106
107
108
Install the gems required by Gitorious
109
======================================
110
111
Gems are handled by Bundler. Install Bundler, then use it to install all of
112
Gitorious' requirements. Note that Gitorious does not work out of the box with
113
RubyGems 1.5, so make sure you're on an earlier version (e.g. 1.4.x).
114
115
  [sudo] gem install bundler
116
  bundle install
117
118
Create your database
119
====================
120
121
It is now time for creating the Gitorious database. 
122
123
  bundle exec rake db:create:all
124
  
125
will create an empty database for you.
126
127
128
Migrate your database
129
=====================
130
131
Now that you have a database, it's time to add the database schema
132
133
  bundle exec rake db:setup
134
  
135
will take care of this for you
136
137
138
Run the tests
139
=============
140
141
Running all the tests will ensure your Gitorious installation is correctly set
142
up. It takes less than a minute to run all the tests, and gives confidence
143
that the code is working as intended.
144
145
  bundle exec rake test
146
  
147
Once all the tests pass, you're almost ready.
148
149
Messaging server
150
================
151
152
Many Gitorious operations are performed asynchronously to ensure good
153
performance. Examples of such tasks includes updating the database when pushing
154
to Gitorious, creating bare git repositories when creating repositories in the
155
web UI and more. To process these asynchronous actions, Gitorious uses a
156
messaging system where it sends messages to a queue, and a worker (i.e. another
157
process, usually some kind of daemon) fetches messages back for processing.
158
159
Gitorious provides several messaging implementations ("adapters"). The
160
alternatives along with how to install and run them are presented below. You
161
only need one of these alternatives.
162
163
Sync adapter
164
------------
165
166
Processes messages synchronously, which means that no extra process is
167
required. This is a very simple solution, but will yield poor performance. It's
168
intended use is for development, but may also fit small setups where performance
169
is not an issue (e.g. if resources are scarce). To use it, simply set
170
messaging_adapter in gitorious.yml to "sync":
171
172
  messaging_adapter: sync
173
174
Stomp adapter
175
-------------
176
177
The default (backwards compatible) adapter. This loads the implementation that's
178
been in Gitorious for a while. If you are upgrading an earlier install, using
179
this adapter will "just work". To use it, set messaging_adapter to "stomp" in
180
gitorious.yml:
181
182
  messaging_adapter: stomp
183
184
The Stomp adapter uses stomp to talk to your Stomp aware message queue of
185
choice. A pretty reliable solution is to use Apache's ActiveMQ messaging queue
186
system, located at http://activemq.apache.org/. Download a version for your
187
operating system, unpack, and follow the instructions to get running. Instructions
188
for installing on Ubuntu can be found in this Gitorious installation guide:
189
http://cjohansen.no/en/ruby/setting_up_gitorious_on_your_own_server
190
191
An init script for ActiveMQ can be found here:
192
http://launchpadlibrarian.net/15645459/activemq
193
With it, starting ActiveMQ is as simple as:
194
195
sudo /etc/init.d/activemq start
196
197
The ActiveMessaging plugin needs to know how to contact your MQ server, so it
198
needs a config/broker.yml file. The Gitorious distribution provides an example
199
(the defaults should work in a development environment). Just copy the
200
config/broker.yml.example file to config/broker.yml and start your server.
201
202
The scripts/poller script uses processors found in app/processors to consume
203
messages from a Stomp queue. The script can be run in a blocking mode (useful in
204
development) by issuing:
205
206
  bundle exec script/poller run
207
208
To start the poller as a non-blocking daemon (as you would in a production
209
environment), issue:
210
211
  bundler exec script/poller start
212
213
Not that Gitorious uses ActiveMessaging to publish messages to the queue. Even
214
though ActiveMessaging supports several brokers, your only option for Gitorious
215
is Stomp. The reason is that we use Stomp directly to consume messages, and in
216
the future we are likely to remove ActiveMessaging alltogether in favor of a
217
direct Stomp implementation.
218
219
Resque adapter
220
--------------
221
222
Resque uses Redis as a backend for messaging. It comes with a nice
223
administration interface that allows for resending of messages, introspection
224
and general statistics about your queue. To use it, set messaging_adapter to
225
"resque" in gitorious.yml:
226
227
  messaging_adapter: resque
228
229
To use Resque, you need to install and run Redis. This is described in detail on
230
the official Resque page: https://github.com/defunkt/resque
231
232
To process messages from the queue with Resque, you need to run rake:
233
234
  RAILS_ENV=production QUEUE=* bundle exec rake environment resque:work
235
236
You can also run a worker for a single, or a handful of queues too. This allows
237
you to assign different priority to different queues. The list of queues in use
238
can be found in lib/gitorious/messaging/resque_adapter.rb.
239
240
Note that Gitorious generally uses JMS style queue names, e.g.
241
/queue/GitoriousPostReceiveWebHook. Because the Resque web frontend does not
242
handle queue names with slashes in them, we strip queue names such that the
243
aforementioned queue will be named GitoriousPostReceiveWebHook under Resque.
244
245
Get Sphinx going
246
================
247
248
  bundle exec rake ultrasphinx:configure RAILS_ENV=production
249
  bundle exec rake ultrasphinx:index RAILS_ENV=production
250
  bundle exec rake ultrasphinx:daemon:start RAILS_ENV=production
251
    
252
This sequence of commands will configure, index the database and start the
253
sphinx daemon
254
  
255
256
Tweak environment
257
=================
258
259
* If you haven't set up your mailer, production mode will fail on login. Set
260
    config.action_mailer.delivery_method = :test
261
  for immediate gratification.
262
263
Start the server
264
================
265
266
Now that you have all the components running, it's time to try Gitorious on
267
your local machine:
268
269
  bundle exec script/server (for Mongrel/Webrick)
270
  thin start                (for Thin)
271
272
Remember the values you put for gitorious_host and gitorious_port in
273
config/gitorious.yml? Go to http://<gitorious_host>:<gitorious_port> to see
274
the main page of your local Gitorious. You are now officially up and running,
275
congratulations!
276
277
Production setup
278
================
279
280
In a production environment, you'll want to automate as much as possible. We
281
use Capistrano for deploying to gitorious.org, and use custom Capistrano
282
recipes for starting and stopping the various tasks in Gitorious.
283
284
The doc/recipes directory contains instructions for setting up init scripts
285
for these tasks for various platforms. Please consult these, and feel free to
286
contribute your own!
287
288
Sphinx
289
------
290
291
The sphinx daemon needs to be running in order for full text search to work.
292
293
Git-daemon
294
----------
295
296
For cloning over the Git protocol, Gitorious includes a custom git daemon
297
found in script/git-daemon. 
298
299
script/poller
300
-------------
301
302
The script/poller script needs to be kept running. 
303
304
Web/application server
305
----------------------
306
307
While Mongrel/thin is great for trying out Gitorious on a local install, in a
308
production environment you'll probably want something a little more robust.
309
Most Rails folks use Passenger with Apache or Nginx these days, Gitorious will
310
play happily in such an environment. 
311
312
Support for pushing via SSH
313
===========================
314
315
In order for people to be able to push to your repositories, you need an SSH
316
daemon running. You'll also need a system user account that's used for git
317
connections through SSH. Consult the recipes in doc/recipes for instructions
318
on how to set this up. Until you've done this, the web frontend will work, but
319
users won't be able to push their changes.
320
321
Button up
322
=========
323
324
* In production, you'll want to have a limited-privileges user to run the git
325
  processes, just as you do for your webserver
326
327
* Make the tree invisible to any other non-root user; make the tree read-only
328
  by that user; but grant write access to the /tmp and /public/cache
329
  directories.
330
331
* Consider setting up the standard (lighttpd|nginx|apache) 
332
  frontend <=> mongrel backend if you see traffic (or configure 
333
  mod_passenger for apache2).
334
335
336
More Help
337
=========
338
339
* Consult the mailinglist (http://groups.google.com/group/gitorious) or drop 
340
  by #gitorious on irc.freenode.net if you have questions.
341
342
Gotchas
343
=======
344
345
Gitorious will add a 'forced command' to your ~/.ssh/authorized_keys file for
346
the target host: if you start finding ssh oddities suspect this first.  Don't
347
log out until you've ensured you can still log in remotely.