forked from gnufied/gitorious
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
331 lines (227 loc) · 10 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
Gitorious.org
=============
Contributing
============
Please see HACKING
License
=======
Please see the LICENSE file
Further documentation
=====================
Also see the files in the doc/ folder, they contain further detailed information
about setting up the application for specific linux distributions such as
CenOS and Ubuntu/Debian
Installation to a production environment -- a partial walkthrough.
==================================================================
Make ready
==========
You may want to make separate directories, away from everything, to hold the
site code and the git repository respectively. In production, you'll be setting
up a special user account too, but don't worry about that yet.
For this intro we're going to use, as examples,
* /www/gitorious -- directory for the website code
* /gitorious/repositories -- root directory for the git repositories
* a MySQL database on localhost at port 3306 with a _mysql_ user 'gitorious'
* eventually, a system account named 'gitslave'
All of these can be adjusted to suit: specifically, dirs within your home
directory are fine, and (though MySQL has the best development coverage), the
website code should be free of mysql-isms/quirks.
Prerequisites
=============
First of all, **we assume you have a working Ruby on Rails installation on
your machine**. The Rails project has several resources about getting up and
running with Rails, have a look at [getting started on
rubyonrails.org](http://rubyonrails.org/download). Please ensure you're able
to create a Rails project that uses your database of choice; this guide
assumes your machine is ready to run Rails.
Gitorious itself runs on either Ruby 1.8 or 1.9. Gitorious.org itself uses
Ruby 1.9 and we recommend you do the same.
Dependencies
============
First, install each of these Libraries/applications:
* Git (http://git-scm.org)
* Sphinx (http://sphinxsearch.com/)
* MySQL (or whatever)
* ImageMagick (need version >= 6.3.0)
* aspell (optional)
An ActiveMessaging (http://code.google.com/p/activemessaging/wiki/Installation) compatible queue
server. Gitorious.org runs ActiveMQ and STOMP, stompserver might be a nice
flyweight alternative for your needs
Getting the code
================
Next, get the gitorious code itself:
# mkdir /www/gitorious ;# or another location of your choice
# cd /www/gitorious
# git clone git://gitorious.org/gitorious/mainline.git gitorious
Now you need edit a couple of configuration files.
config/database.yml
------------------
This file contains settings for the databases used for Gitorious. The
Gitorious distribution provides a sample config file - database.sample.yml -
that you could copy to config/database.yml.
Gitorious should be database agnostic, so feel free to use your database of
choice. Gitorious.org uses MySQL, but there shouldn't be any MySQL specific
code in Gitorious, so use whatever you're most comfortable with.
config/gitorious.yml
--------------------
This file holds Gitorious specific configuration for each Rails environment.
There's a sample file in config/gitorious.sample.yml that describes what each
instruction means. Do make sure you have a section for each Rails environment,
especially if you're upgrading an existing Gitorious installation.
* Create a directory to hold project files
# sudo mkdir /gitorious/repositories
* Add the path to this directory under repository_base_path in gitorious.yml
* Make a long, complicated string. You can run "apg -m 64", or if you lack 'apg'
`dd if=/dev/random count=1 | md5sum` ,
and put that on the 'cookie_secret' line (replacing the 'ssssht').
config/broker.yml
-----------------
This file contains information about the Message Queing system used in your
Gitorious installation. There's a section about this further down in this
document, but as a starting point you can use the supplied sample file in
config/broker.yml.example (cp config/broker.yml.example config/broker.yml)
Install the gems required by Gitorious
======================================
Next, you need to install a couple of gems:
* chronic
* daemons
* diff-lcs
* echoe
* fastthread
* geoip
* highline
* hoe
* mime-types
* oauth
* rack >= 1.0.0
* rake
* rdiscount >= 1.3.1.1
* RedCloth
* rmagick
* ruby-hmac
* ruby-openid
* ruby-yadis
* stomp >= 1.1
Most of these can be installed using
$ [sudo] rake gems:install
Create your database
====================
It is now time for creating the Gitorious database.
rake db:create:all
will create an empty database for you.
Migrate your database
=====================
Now that you have a database, it's time to add the database schema
rake db:migrate
will take care of this for you
Run the tests
=============
Running all the tests will ensure your Gitorious installation is correctly set
up. It takes less than a minute to run all the tests, and gives confidence
that the code is working as intended.
There is at the time being one gem that's required to run the tests, so start
out with
[sudo] rake gems:install RAILS_ENV=test
to make sure the test specific gems are installed. Then run the entire test
suite:
rake test
Once all the tests pass, you're almost ready.
Messaging server
================
Gitorious uses the ActiveMessaging plugin, which supports a range of different
messaging platforms, for sending demanding tasks for asynchronous processing.
In order to these events to be processed, you need to run a messaging server
when running Gitorious.
A pretty reliable solution is to use Apache's ActiveMQ messaging queue system,
located at http://activemq.apache.org/ . Download a version for you operating
system, unpack, and follow the instructions to get running. On Unix-like
systems, this is as easy as unpacking the tarball, going into it and running
bin/activemq
This will start the ActiveMQ server in a default setup, probably pretty well
suited for development purposes. The ActiveMessaging plugin needs to know how
to contact your MQ server, so it needs a config/broker.yml file. The Gitorious
distribution provides an example (again, the defaults should work in a
development environment). Just copy the config/broker.yml.example to
config/broker.yml and start your server.
The messages are sent to the server, in order to "consume" the messages, there
is a script in scripts/poller that will run all registered "processors" (found
in app/processors) that consume messages. In order to have eg. creation of
repositories done automatically run
script/poller start
and the script will be started and daemonized.
You're free to use other messaging protocols than the default Stomp protocol,
which is required in config/environment.rb. The ActiveMessaging website
(http://code.google.com/p/activemessaging/wiki/ActiveMessaging) has more
information about how to set this up.
Get Sphinx going
================
$ env RAILS_ENV=production rake ultrasphinx:configure
$ env RAILS_ENV=production rake ultrasphinx:index
$ env RAILS_ENV=production rake ultrasphinx:daemon:start
This sequence of commands will configure, index the database and start the
sphinx daemon
Tweak environment
=================
* If you haven't set up your mailer, production mode will fail on login. Set
config.action_mailer.delivery_method = :test
for immediate gratification.
Start the server
================
Now that you have all the components running, it's time to try Gitorious on
your local machine:
ruby script/server (for Mongrel/Webrick)
thin start (for Thin)
Remember the values you put for gitorious_host and gitorious_port in
config/gitorious.yml? Go to http://<gitorious_host>:<gitorious_port> to see
the main page of your local Gitorious. You are now officially up and running,
congratulations!
Production setup
================
In a production environment, you'll want to automate as much as possible. We
use Capistrano for deploying to gitorious.org, and use custom Capistrano
recipes for starting and stopping the various tasks in Gitorious.
The doc/recipies directory contains instructions for setting up init scripts
for these tasks for various platforms. Please consult these, and feel free to
contribute your own!
Sphinx
------
The sphinx daemon needs to be running in order for full text search to work.
Git-daemon
----------
For cloning over the Git protocol, Gitorious includes a custom git daemon
found in script/git-daemon.
script/poller
-------------
The script/poller script needs to be kept running.
Web/application server
----------------------
While Mongrel/thin is great for trying out Gitorious on a local install, in a
production environment you'll probably want something a little more robust.
Most Rails folks use Passenger with Apache or Nginx these days, Gitorious will
play happily in such an environment.
Support for pushing via SSH
===========================
In order for people to be able to push to your repositories, you need an SSH
daemon running. You'll also need a system user account that's used for git
connections through SSH. Consult the recipies in doc/recipies for instructions
on how to set this up. Until you've done this, the web frontend will work, but
users won't be able to push their changes.
Button up
=========
* In production, you'll want to have a limited-privileges user to run the git
processes, just as you do for your webserver
* Make the tree invisible to any other non-root user; make the tree read-only
by that user; but grant write access to the /tmp and /public/cache
directories.
* Consider setting up the standard (lighttpd|nginx|apache)
frontend <=> mongrel backend if you see traffic (or configure
mod_passenger for apache2).
More Help
=========
* Consult the mailinglist (http://groups.google.com/group/gitorious) or drop
by #gitorious on irc.freenode.net if you have questions.
Gotchas
=======
Gitorious will add a 'forced command' to your ~/.ssh/authorized_keys file for
the target host: if you start finding ssh oddities suspect this first. Don't
log out until you've ensured you can still log in remotely.