forked from TechEmpower/FrameworkBenchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer.py
307 lines (253 loc) · 11.7 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
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", True)
self.__run_command("cp ../config/benchmark_profile ../../.bash_profile")
#######################################
# Languages
#######################################
#
# 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.0/node-v0.10.0-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 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.0.3.linux-amd64.tar.gz | tar xvz")
#
# php
#
self.__run_command("sudo apt-get install php5 php5-mysql", 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")
#
# Gunicorn
#
self.__run_command("sudo easy_install -U 'gunicorn==0.17.2'")
self.__run_command("sudo easy_install -U 'eventlet==0.12.1'")
#
# 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")
##############################
# 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")
##############################
# Play
##############################
self.__run_command("wget http://downloads.typesafe.com/play/2.1.0/play-2.1.0.zip")
self.__run_command("unzip -o play-2.1.0.zip")
self.__run_command("rm play-2.1.0.zip")
##############################
# Vert.x
##############################
self.__run_command("curl http://vertx.io/downloads/vert.x-1.3.1.final.tar.gz | tar xvz")
##############################
# WebGO
##############################
self.__run_command("go/bin/go get github.com/hoisie/web")
##############################################################
#
# 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
##############################
# 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 ~
##############################
# MongoDB
##############################
yes | sudo apt-get install mongodb
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__
############################################################