forked from TechEmpower/FrameworkBenchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer.py
372 lines (308 loc) · 14.6 KB
/
installer.py
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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
import subprocess
import os
class Installer:
############################################################
# install_software
############################################################
def install_software(self):
self.__install_server_software()
self.__install_client_software()
############################################################
# End install_software
############################################################
############################################################
# __install_server_software
############################################################
def __install_server_software(self):
#######################################
# Prerequisites
#######################################
self.__run_command("sudo apt-get update", True)
self.__run_command("sudo apt-get upgrade", True)
self.__run_command("sudo apt-get install build-essential libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev python-software-properties unzip git-core libcurl4-openssl-dev libbz2-dev libmysqlclient-dev mongodb-clients libreadline6-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev libgdbm-dev ncurses-dev automake libffi-dev htop libtool bison libevent-dev libgstreamer-plugins-base0.10-0 libgstreamer0.10-0 liborc-0.4-0 libwxbase2.8-0 libwxgtk2.8-0 libgnutls-dev libjson0-dev libmcrypt-dev", True)
self.__run_command("cp ../config/benchmark_profile ../../.bash_profile")
self.__run_command("sudo sh -c \"echo '* soft nofile 4096' >> /etc/security/limits.conf\"")
#######################################
# Languages
#######################################
#
# Erlang
#
self.__run_command("sudo cp ../config/erlang.list /etc/apt/sources.list.d/erlang.list")
self.__run_command("wget -O - http://binaries.erlang-solutions.com/debian/erlang_solutions.asc | sudo apt-key add -")
self.__run_command("sudo apt-get update")
self.__run_command("sudo apt-get install esl-erlang", True)
#
# Python
#
self.__run_command("curl http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz | tar xvz")
self.__run_command("./configure", cwd="Python-2.7.3")
self.__run_command("sudo make install", cwd="Python-2.7.3")
self.__run_command("curl http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz | tar xvz")
self.__run_command("sudo python setup.py install", cwd="setuptools-0.6c11")
self.__run_command("curl http://pypi.python.org/packages/source/p/pip/pip-1.1.tar.gz | tar xvz")
self.__run_command("sudo python setup.py install", cwd="pip-1.1")
self.__run_command("sudo pip install MySQL-python==1.2.4")
self.__run_command("sudo pip install simplejson==3.0.7")
#
# nodejs
#
self.__run_command("curl http://nodejs.org/dist/v0.10.2/node-v0.10.2-linux-x64.tar.gz | tar xvz")
#
# Java
#
self.__run_command("sudo apt-get install openjdk-7-jdk", True)
self.__run_command("sudo apt-get remove --purge openjdk-6-jre openjdk-6-jre-headless", True)
#
# Ruby/JRuby
#
self.__run_command("curl -L get.rvm.io | bash -s head")
self.__run_command("echo rvm_auto_reload_flag=2 >> ~/.rvmrc")
subprocess.call(["bash", "-c", "source ~/.rvm/scripts/'rvm' && rvm install 2.0.0-p0"])
subprocess.call(["bash", "-c", "source ~/.rvm/scripts/'rvm' && rvm 2.0.0-p0 do gem install bundler"])
subprocess.call(["bash", "-c", "source ~/.rvm/scripts/'rvm' && rvm install jruby-1.7.3"])
subprocess.call(["bash", "-c", "source ~/.rvm/scripts/'rvm' && rvm jruby-1.7.3 do gem install bundler"])
# We need a newer version of jruby-rack
self.__run_command("git clone git://github.com/jruby/jruby-rack.git")
subprocess.call(["bash", "-c", "cd installs/jruby-rack && source ~/.rvm/scripts/'rvm' && rvm jruby-1.7.3 do bundle install"])
subprocess.call(["bash", "-c", "cd installs/jruby-rack && source ~/.rvm/scripts/'rvm' && rvm jruby-1.7.3 do jruby -S bundle exec rake clean gem SKIP_SPECS=true"])
subprocess.call(["bash", "-c", "cd installs/jruby-rack/target && source ~/.rvm/scripts/'rvm' && rvm jruby-1.7.3 do gem install jruby-rack-1.2.0.SNAPSHOT.gem"])
#
# go
#
self.__run_command("curl http://go.googlecode.com/files/go1.1beta1.linux-amd64.tar.gz | tar xvz")
#
# php
#
self.__run_command("wget --trust-server-names http://www.php.net/get/php-5.4.13.tar.gz/from/us1.php.net/mirror")
self.__run_command("tar xvf php-5.4.13.tar.gz")
self.__run_command("./configure --with-pdo-mysql --with-mysql --with-mcrypt --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data", cwd="php-5.4.13")
self.__run_command("make", cwd="php-5.4.13")
self.__run_command("sudo make install", cwd="php-5.4.13")
self.__run_command("printf \"\\n\" | sudo pecl install apc-beta", cwd="php-5.4.13")
self.__run_command("sudo cp ../config/php.ini /usr/local/lib/php.ini")
self.__run_command("sudo cp ../config/php-fpm.conf /usr/local/lib/php-fpm.conf")
self.__run_command("rm php-5.4.13.tar.gz")
# Composer
self.__run_command("curl -sS https://getcomposer.org/installer | php -- --install-dir=bin")
#
# Haskell
#
self.__run_command("sudo apt-get install ghc cabal-install", True)
#######################################
# Webservers
#######################################
#
# Apache
#
self.__run_command("sudo apt-get install apache2 libapache2-mod-php5", True)
self.__run_command("sudo mv /etc/apache2/apache2.conf /etc/apache2/apache2.conf.orig")
self.__run_command("sudo sh -c \"cat ../config/apache2.conf > /etc/apache2/apache2.conf\"")
self.__run_command("sudo mv /etc/apache2/ports.conf /etc/apache2/ports.conf.orig")
self.__run_command("sudo sh -c \"cat ../config/ports.conf > /etc/apache2/ports.conf\"")
self.__run_command("sudo /etc/init.d/apache2 stop")
#
# Nginx
#
self.__run_command("curl http://nginx.org/download/nginx-1.2.7.tar.gz | tar xvz")
self.__run_command("./configure", cwd="nginx-1.2.7")
self.__run_command("make", cwd="nginx-1.2.7")
self.__run_command("sudo make install", cwd="nginx-1.2.7")
#
# Openresty (nginx with openresty stuff)
#
self.__run_command("curl http://openresty.org/download/ngx_openresty-1.2.7.5.tar.gz | tar xvz")
self.__run_command("./configure --with-luajit", cwd="ngx_openresty-1.2.7.5")
self.__run_command("make", cwd="ngx_openresty-1.2.7.5")
self.__run_command("sudo make install", cwd="ngx_openresty-1.2.7.5")
#
# Gunicorn
#
self.__run_command("sudo easy_install -U 'gunicorn==0.17.2'")
self.__run_command("sudo easy_install -U 'eventlet==0.12.1'")
self.__run_command("sudo pip install --upgrade 'gevent==0.13.8'")
#
# Resin
#
self.__run_command("sudo cp -r /usr/lib/jvm/java-1.7.0-openjdk-amd64/include /usr/lib/jvm/java-1.7.0-openjdk-amd64/jre/bin/")
self.__run_command("curl http://www.caucho.com/download/resin-4.0.34.tar.gz | tar xvz")
self.__run_command("./configure --prefix=`pwd`", cwd="resin-4.0.34")
self.__run_command("make", cwd="resin-4.0.34")
self.__run_command("make install", cwd="resin-4.0.34")
self.__run_command("mv conf/resin.properties conf/resin.properties.orig", cwd="resin-4.0.34")
self.__run_command("cat ../config/resin.properties > resin-4.0.34/conf/resin.properties")
#
# Passenger
#
self.__run_command("git clone https://github.com/FooBarWidget/passenger.git")
self.__run_command("git checkout 65d36dbbadd399f65d81f5febadce9b0c6c1a430", cwd="passenger")
subprocess.call(["bash", "-c", "cd installs/passenger && source ~/.rvm/scripts/'rvm' && rvm 2.0.0-p0 do gem build passenger.gemspec"])
subprocess.call(["bash", "-c", "cd installs/passenger && source ~/.rvm/scripts/'rvm' && rvm 2.0.0-p0 do gem install passenger-3.9.5.rc3.gem"])
##############################
# Tomcat
# We don't use tomcat in our tests yet, but this is here to remind us of how we
# installed the apr connector
##############################
self.__run_command("curl http://apache.cs.utah.edu/tomcat/tomcat-7/v7.0.35/bin/apache-tomcat-7.0.35.tar.gz | tar xvz")
#wget http://apache.cs.utah.edu/tomcat/tomcat-7/v7.0.35/bin/apache-tomcat-7.0.35.tar.gz
#tar -xvzf apache-tomcat-7.0.35.tar.gz
#rm apache-tomcat-7.0.35.tar.gz
# use the native APR
# http://evgeny-goldin.com/blog/ubuntu-installing-apr-tomcat/
#wget http://apache.claz.org/apr/apr-1.4.6.tar.gz
#tar xvf apr-1.4.6.tar.gz
#cd apr-1.4.6
#./configure
#make
#sudo make install
#cd ..
#rm apr-1.4.6.tar.gz
#wget http://apache.tradebit.com/pub/tomcat/tomcat-connectors/native/1.1.24/source/tomcat-native-1.1.24-src.tar.gz
#tar xvf tomcat-native-1.1.24-src.tar.gz
#cd tomcat-native-1.1.24-src/jni/native
#./configure --with-apr=/usr/local/apr
#make
#sudo make install
#cd ../../..
#rm tomcat-native-1.1.24-src.tar.gz
##############################################################
#
# Frameworks
#
##############################################################
##############################
# Django
##############################
self.__run_command("curl http://www.djangoproject.com/m/releases/1.4/Django-1.4.tar.gz | tar xvz")
self.__run_command("sudo rm -rf /usr/local/lib/python2.7/site-packages/django")
self.__run_command("sudo python setup.py install", cwd="Django-1.4")
self.__run_command("sudo easy_install -U 'ujson==1.30'")
##############################
# Grails
##############################
self.__run_command("wget http://dist.springframework.org.s3.amazonaws.com/release/GRAILS/grails-2.1.1.zip")
self.__run_command("unzip -o grails-2.1.1.zip")
self.__run_command("rm grails-2.1.1.zip")
##############################
# Flask
##############################
self.__run_command("sudo pip install flask flask-sqlalchemy")
##############################
# Play
##############################
self.__run_command("wget http://downloads.typesafe.com/play/2.1.1/play-2.1.1.zip")
self.__run_command("unzip -o play-2.1.1.zip")
self.__run_command("rm play-2.1.1.zip")
##############################
# Vert.x
##############################
self.__run_command("curl http://vertx.io/downloads/vert.x-1.3.1.final.tar.gz | tar xvz")
##############################
# Yesod
##############################
self.__run_command("cabal update")
self.__run_command("cabal install yesod persistent-mysql")
##############################################################
#
# System Tools
#
##############################################################
##############################
# Maven
##############################
self.__run_command("sudo apt-get install maven2", send_yes=True)
##############################
# Leiningen
##############################
self.__run_command("mkdir -p bin")
self.__run_command("wget https://raw.github.com/technomancy/leiningen/stable/bin/lein")
self.__run_command("mv lein bin/lein")
self.__run_command("chmod +x bin/lein")
############################################################
# End __install_server_software
############################################################
############################################################
# __install_client_software
############################################################
def __install_client_software(self):
subprocess.call(self.benchmarker.sftp_string(batch_file="config/client_sftp_batch"), shell=True)
remote_script = """
##############################
# Prerequisites
##############################
yes | sudo apt-get update
yes | sudo apt-get install build-essential git libev-dev libpq-dev libreadline6-dev
sudo sh -c "echo '* soft nofile 4096' >> /etc/security/limits.conf"
##############################
# MySQL
##############################
sudo sh -c "echo mysql-server mysql-server/root_password_again select secret | debconf-set-selections"
sudo sh -c "echo mysql-server mysql-server/root_password select secret | debconf-set-selections"
yes | sudo apt-get install mysql-server
# use the my.cnf file to overwrite /etc/mysql/my.cnf
sudo mv /etc/mysql/my.cnf /etc/mysql/my.cnf.orig
sudo mv my.cnf /etc/mysql/my.cnf
sudo restart mysql
# Insert data
mysql -uroot -psecret < create.sql
##############################
# Weighttp
##############################
git clone git://git.lighttpd.net/weighttp
cd weighttp
./waf configure
./waf build
sudo ./waf install
cd ~
##############################
# wrk
##############################
git clone https://github.com/wg/wrk.git
cd wrk
make
sudo cp wrk /usr/local/bin
cd ~
##############################
# MongoDB
##############################
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
sudo cp 10gen.list /etc/apt/sources.list.d/10gen.list
sudo apt-get update
yes | sudo apt-get install mongodb-10gen
sudo mv /etc/mongodb.conf /etc/mongodb.conf.orig
sudo mv mongodb.conf /etc/mongodb.conf
sudo restart mongodb
"""
p = subprocess.Popen(self.benchmarker.ssh_string.split(" "), stdin=subprocess.PIPE)
p.communicate(remote_script)
############################################################
# End __parse_results
############################################################
############################################################
# __run_command
############################################################
def __run_command(self, command, send_yes=False, cwd=None):
try:
cwd = os.path.join(self.install_dir, cwd)
except AttributeError:
cwd = self.install_dir
if send_yes:
subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, cwd=cwd).communicate("yes")
else:
subprocess.call(command, shell=True, cwd=cwd)
############################################################
# End __run_command
############################################################
############################################################
# __init__(benchmarker)
############################################################
def __init__(self, benchmarker):
self.benchmarker = benchmarker
self.install_dir = "installs"
try:
os.mkdir(self.install_dir)
except OSError:
pass
############################################################
# End __init__
############################################################