Skip to content

Commit

Permalink
Fixing a lot of production-only issues
Browse files Browse the repository at this point in the history
  • Loading branch information
msmith-techempower committed Jul 6, 2015
1 parent e3a2073 commit 9923de5
Show file tree
Hide file tree
Showing 32 changed files with 66 additions and 41 deletions.
13 changes: 4 additions & 9 deletions config/create.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
# create benchmark user
REVOKE ALL ON *.* FROM 'benchmarkdbuser'@'%';
REVOKE ALL ON *.* FROM 'benchmarkdbuser'@'localhost';

GRANT ALL ON hello_world.world TO 'benchmarkdbuser'@'%' IDENTIFIED BY 'benchmarkdbpass';
GRANT ALL ON hello_world.world TO 'benchmarkdbuser'@'localhost' IDENTIFIED BY 'benchmarkdbpass';
GRANT SELECT ON hello_world.fortune TO 'benchmarkdbuser'@'%' IDENTIFIED BY 'benchmarkdbpass';
GRANT SELECT ON hello_world.fortune TO 'benchmarkdbuser'@'localhost' IDENTIFIED BY 'benchmarkdbpass';

# modified from SO answer http://stackoverflow.com/questions/5125096/for-loop-in-mysql
DROP DATABASE IF EXISTS hello_world;
CREATE DATABASE hello_world;
Expand All @@ -19,6 +10,8 @@ CREATE TABLE World (
PRIMARY KEY (id)
)
ENGINE=INNODB;
GRANT ALL ON hello_world.world TO 'benchmarkdbuser'@'%' IDENTIFIED BY 'benchmarkdbpass';
GRANT ALL ON hello_world.world TO 'benchmarkdbuser'@'localhost' IDENTIFIED BY 'benchmarkdbpass';

DROP PROCEDURE IF EXISTS load_data;

Expand Down Expand Up @@ -100,6 +93,8 @@ CREATE TABLE fortune (
PRIMARY KEY (id)
)
ENGINE=INNODB;
GRANT SELECT ON hello_world.fortune TO 'benchmarkdbuser'@'%' IDENTIFIED BY 'benchmarkdbpass';
GRANT SELECT ON hello_world.fortune TO 'benchmarkdbuser'@'localhost' IDENTIFIED BY 'benchmarkdbpass';

INSERT INTO fortune (message) VALUES ('fortune: No such file or directory');
INSERT INTO fortune (message) VALUES ('A computer scientist is someone who fixes things that aren''t broken.');
Expand Down
2 changes: 1 addition & 1 deletion frameworks/C/onion/hello.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ int main(void){
ONION_ERROR("Cant create db connection: %s", mysql_error(data.db[i]));
return 1;
}
if (mysql_real_connect(data.db[i], "localhost",
if (mysql_real_connect(data.db[i], "127.0.0.1",
"benchmarkdbuser", "benchmarkdbpass", "hello_world", 0, NULL, 0) == NULL) {
ONION_ERROR("Error %u: %s\n", mysql_errno(data.db[i]), mysql_error(data.db[i]));
return 1;
Expand Down
2 changes: 2 additions & 0 deletions frameworks/C/onion/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

fw_depends onion

sed -i 's|127.0.0.1|'${DBHOST}'|g' hello.c

make clean
ln -s $IROOT/onion onion
rm -f onion/build/CMakeCache.txt
Expand Down
2 changes: 2 additions & 0 deletions frameworks/Clojure/pedestal/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

fw_depends java7 leiningen

sed -i 's|127.0.0.1:3306|'${DBHOST}':3306|g' src/pedestal/service.clj

lein clean

rm -rf target
Expand Down
2 changes: 1 addition & 1 deletion frameworks/Clojure/pedestal/src/pedestal/service.clj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
(mysql {
:classname "com.mysql.jdbc.Driver"
:subprotocol "mysql"
:subname "//localhost:3306/hello_world"
:subname "//127.0.0.1:3306/hello_world"
:user "benchmarkdbuser"
:password "benchmarkdbpass"
;;OPTIONAL KEYS
Expand Down
4 changes: 2 additions & 2 deletions frameworks/Elixir/phoenix/setup.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

sed -i 's|db_host: "localhost",|db_host: "${DBHOST}",|g' config/config.exs

fw_depends elixir

sed -i 's|localhost|'${DBHOST}'|g' config/prod.exs

rm -rf _build deps rel

MIX_ENV=prod
Expand Down
4 changes: 3 additions & 1 deletion frameworks/Java/jawn/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

fw_depends java8

sed -i 's|127.0.0.1|'${DBHOST}'|g' src/main/java/app/config/Database.java

./gradlew clean --daemon

./gradlew run -Pargs=production,$DBHOST
./gradlew run -Pargs=production &
5 changes: 2 additions & 3 deletions frameworks/Java/jawn/src/main/java/app/config/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ public void dbConnections(DatabaseConnections connections) {
"&useUnbufferedInput=false" +
"&useReadAheadInput=false" +
"&maintainTimeStats=false" +
"&useServerPrepStmts" +
"&useServerPrepStmts=true" +
"&cacheRSMetadata=true";

String host = System.getProperty("DBHOST", "localhost");
String dbUrl = "jdbc:mysql://"+host+"/hello_world?";
String dbUrl = "jdbc:mysql://127.0.0.1:3306/hello_world?";


connections
Expand Down
4 changes: 2 additions & 2 deletions frameworks/Java/mangooio/setup.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

sed -i 's|mongodb.host=.*|mongodb.host='"${DBHOST}"'|g' src/main/resources/application.conf

fw_depends java8 maven

sed -i 's|mongodb.host=.*|mongodb.host='${DBHOST}'|g' src/main/resources/application.conf

mvn clean package -Dmaven.test.skip=true

java -jar target/mangooioapp.jar &
4 changes: 2 additions & 2 deletions frameworks/Java/mangooio/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# would overwrite the property
# myproperty=my property

application.host=localhost
application.host=0.0.0.0
application.port=8080
%test.application.host=localhost
%test.application.port=10808
Expand All @@ -31,7 +31,7 @@ smtp.username=
smtp.password=
smtp.ssl=false

mongodb.host127.0.0.1
mongodb.host=127.0.0.1
mongodb.port=27017
mongodb.dbname=hello_world
mongodb.user=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ application.langs="en"
# You can expose this datasource via JNDI if needed (Useful for JPA)
# db.default.jndiName=DefaultDS
db.default.driver= com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://localhost:3306/hello_world?jdbcCompliantTruncation=false&elideSetAutoCommits=true&useLocalSessionState=true&cachePrepStmts=true&cacheCallableStmts=true&alwaysSendSetIsolation=false&prepStmtCacheSize=4096&cacheServerConfiguration=true&prepStmtCacheSqlLimit=2048&zeroDateTimeBehavior=convertToNull&traceProtocol=false&useUnbufferedInput=false&useReadAheadInput=false&maintainTimeStats=false&useServerPrepStmts&cacheRSMetadata=true"
db.default.url="jdbc:mysql://127.0.0.1:3306/hello_world?jdbcCompliantTruncation=false&elideSetAutoCommits=true&useLocalSessionState=true&cachePrepStmts=true&cacheCallableStmts=true&alwaysSendSetIsolation=false&prepStmtCacheSize=4096&cacheServerConfiguration=true&prepStmtCacheSqlLimit=2048&zeroDateTimeBehavior=convertToNull&traceProtocol=false&useUnbufferedInput=false&useReadAheadInput=false&maintainTimeStats=false&useServerPrepStmts&cacheRSMetadata=true"
db.default.user=benchmarkdbuser
db.default.password=benchmarkdbpass
db.default.jndiName=DefaultDS
Expand Down
2 changes: 2 additions & 0 deletions frameworks/Java/play2-java/setup_java_ebean_bonecp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

fw_depends java8 sbt

sed -i 's|127.0.0.1:3306|'${DBHOST}':3306|g' play2-java-ebean-bonecp/conf/application.conf

cd play2-java-ebean-bonecp

rm -rf target/universal/stage/RUNNING_PID
Expand Down
2 changes: 2 additions & 0 deletions frameworks/Java/play2-java/setup_java_ebean_hikaricp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

fw_depends java8 sbt

sed -i 's|127.0.0.1|'${DBHOST}'|g' play2-java-ebean-hikaricp/conf/application.conf

cd play2-java-ebean-hikaricp

rm -rf target/universal/stage/RUNNING_PID
Expand Down
2 changes: 2 additions & 0 deletions frameworks/Java/play2-java/setup_java_jpa_bonecp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

fw_depends java8 sbt

sed -i 's|127.0.0.1|'${DBHOST}'|g' play2-java-jpa-bonecp/conf/application.conf

cd play2-java-jpa-bonecp

rm -rf target/universal/stage/RUNNING_PID
Expand Down
2 changes: 2 additions & 0 deletions frameworks/Java/play2-java/setup_java_jpa_hikaricp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

fw_depends java8 sbt

sed -i 's|127.0.0.1|'${DBHOST}'|g' play2-java-jpa-hikaricp/conf/application.conf

cd play2-java-jpa-hikaricp

rm -rf target/universal/stage/RUNNING_PID
Expand Down
2 changes: 1 addition & 1 deletion frameworks/JavaScript/hapi/handlers/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var Promise = require('bluebird');
// Can treat redis library as one that supports Promises
// these methods will then have "-Async" appended to them.
var redis = Promise.promisifyAll(require('redis'));
var client = redis.createClient();
var client = redis.createClient(6379, '127.0.0.1', {});

client.on('error', function (err) {
console.log('Redis Error: ' + err);
Expand Down
7 changes: 5 additions & 2 deletions frameworks/JavaScript/hapi/setup.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/bin/bash

sed -i 's|localhost|'"${DBHOST}"'|g' app.js

fw_depends nodejs

sed -i 's|127.0.0.1|'"${DBHOST}"'|g' handlers/mongoose.js
sed -i 's|127.0.0.1|'"${DBHOST}"'|g' handlers/sequelize-postgres.js
sed -i 's|127.0.0.1|'"${DBHOST}"'|g' handlers/sequelize.js
sed -i 's|127.0.0.1|'"${DBHOST}"'|g' handlers/redis.js

npm install
node app &
2 changes: 1 addition & 1 deletion frameworks/JavaScript/nodejs/handlers/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var async = require('async');
// Otherwise, a pure JavaScript parser will be used."
// >> hiredis is installed for these tests
var redis = require('redis');
var client = redis.createClient();
var client = redis.createClient(6379, '127.0.0.1', {});

client.on('error', function (err) {
console.log('Redis Error: ' + err);
Expand Down
7 changes: 5 additions & 2 deletions frameworks/JavaScript/nodejs/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

fw_depends nodejs

sed -i 's|localhost|'"${DBHOST}"'|g' app.js
sed -i 's|mongodb://.*/hello_world|mongodb://'"${DBHOST}"'/hello_world|g' app.js
sed -i 's|127.0.0.1|'"${DBHOST}"'|g' handlers/mongodb-raw.js
sed -i 's|127.0.0.1|'"${DBHOST}"'|g' handlers/mongoose.js
sed -i 's|127.0.0.1|'"${DBHOST}"'|g' handlers/mysql-raw.js
sed -i 's|127.0.0.1|'"${DBHOST}"'|g' handlers/redis.js
sed -i 's|127.0.0.1|'"${DBHOST}"'|g' handlers/sequelize.js

npm install
node app.js &
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var Promise = require('bluebird')
// Can treat redis library as one that supports Promises
// these methods will then have "-Async" appended to them.
var redis = Promise.promisifyAll(require('redis'))
var client = redis.createClient()
var client = redis.createClient(6379, '127.0.0.1', {})

client.on('error', function (err) {
console.log('Redis Error: ' + err)
Expand Down
1 change: 1 addition & 0 deletions frameworks/JavaScript/sailsjs/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

fw_depends nodejs

sed -i 's|127.0.0.1|'"${DBHOST}"'|g' api/controllers/Redis.js
sed -i 's|127.0.0.1|'"${DBHOST}"'|g' api/controllers/SequelizeMySQLController.js
sed -i 's|127.0.0.1|'"${DBHOST}"'|g' api/controllers/SequelizePostgresController.js

Expand Down
2 changes: 2 additions & 0 deletions frameworks/Python/AsyncIO/aiohttp.web/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

fw_depends python3

sed -i 's|host: 127.0.0.1|host: '${DBHOST}'|g' aiohttp.web/etc/hello/main/main.yaml

pip install --install-option="--prefix=${PY3_ROOT}" -r $TROOT/requirements.txt

cd $TROOT/aiohttp.web
Expand Down
4 changes: 2 additions & 2 deletions frameworks/Python/cherrypy/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ def fortune(self):
# Register the SQLAlchemy plugin
from saplugin import SAEnginePlugin
DBDRIVER = 'mysql'
DBHOSTNAME = os.environ.get('DBHOST', 'localhost')
DATABASE_URI = '%s://benchmarkdbuser:benchmarkdbpass@%s:3306/hello_world?charset=utf8' % (DBDRIVER, DBHOSTNAME)
DATABASE_URI = '%s://benchmarkdbuser:[email protected]:3306/hello_world?charset=utf8' % (DBDRIVER)
SAEnginePlugin(cherrypy.engine, DATABASE_URI).subscribe()

# Register the SQLAlchemy tool
from satool import SATool
cherrypy.tools.db = SATool()
cherrypy.server.socket_host = '0.0.0.0'
cherrypy.quickstart(CherryPyBenchmark(), '', {'/': {'tools.db.on': True}})
2 changes: 2 additions & 0 deletions frameworks/Python/cherrypy/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

fw_depends python2

sed -i 's|127.0.0.1|'${DBHOST}'|g' app.py

pip install --install-option="--prefix=${PY2_ROOT}" -r $TROOT/requirements.txt

python app.py &
2 changes: 2 additions & 0 deletions frameworks/Python/cherrypy/setup_py3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

fw_depends python3

sed -i 's|127.0.0.1|'${DBHOST}'|g' app.py

pip install --install-option="--prefix=${PY3_ROOT}" -r $TROOT/requirements.txt

python3 app.py &
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PlugInDirs = [WebwarePath] # load all Webware plug-ins
PlugIns = [] # use this if you want to load specific plug-ins only

# This is the IP address at which the application server will listen:
Host = 'localhost' # use '' for listening on all network interfaces
Host = '' # use '' for listening on all network interfaces

EnableAdapter = True # enable WebKit adapter
AdapterPort = 8086
Expand Down
4 changes: 1 addition & 3 deletions frameworks/Python/klein/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
if sys.version_info[0] == 3:
xrange = range

DBDRIVER = 'mysql'
DBHOSTNAME = os.environ.get('DBHOST', 'localhost')
DATABASE_URI = '%s://benchmarkdbuser:benchmarkdbpass@%s:3306/hello_world?charset=utf8' % (DBDRIVER, DBHOSTNAME)
DATABASE_URI = 'mysql://benchmarkdbuser:[email protected]:3306/hello_world?charset=utf8'

Base = declarative_base()
db_engine = create_engine(DATABASE_URI)
Expand Down
2 changes: 2 additions & 0 deletions frameworks/Python/klein/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

fw_depends python2

sed -i 's|127.0.0.1|'${DBHOST}'|g' app.py

pip install --install-option="--prefix=${PY2_ROOT}" -r $TROOT/requirements.txt

python app.py &
3 changes: 3 additions & 0 deletions frameworks/Scala/akka-http/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

fw_depends java8 sbt

sed -i 's|dbhost: "0.0.0.0"|dbhost: "'${DBHOST}'"|g' src/main/resources/application.conf
sed -i 's|0.0.0.0:3306|'${DBHOST}':3306|g' src/main/resources/application.conf

sbt 'assembly'

java -server -jar target/scala-2.11/akka-http-benchmark.jar &
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ akka {
port: 9000
mysql {
dbhost: "0.0.0.0"
dbhost: ${?DATABASE_HOST}
dbuser: root
dbpass: ""
jdbc-url: "jdbc:mysql://"${akka.http.benchmark.mysql.dbhost}":3306/hello_world?jdbcCompliantTruncation=false&elideSetAutoCommits=true&useLocalSessionState=true&cachePrepStmts=true&cacheCallableStmts=true&alwaysSendSetIsolation=false&prepStmtCacheSize=4096&cacheServerConfiguration=true&prepStmtCacheSqlLimit=2048&zeroDateTimeBehavior=convertToNull&traceProtocol=false&useUnbufferedInput=false&useReadAheadInput=false&maintainTimeStats=false&useServerPrepStmts&cacheRSMetadata=true"
dbuser: "benchmarkdbuser"
dbpass: "benchmarkdbpass"
jdbc-url: "jdbc:mysql://0.0.0.0:3306/hello_world?jdbcCompliantTruncation=false&elideSetAutoCommits=true&useLocalSessionState=true&cachePrepStmts=true&cacheCallableStmts=true&alwaysSendSetIsolation=false&prepStmtCacheSize=4096&cacheServerConfiguration=true&prepStmtCacheSqlLimit=2048&zeroDateTimeBehavior=convertToNull&traceProtocol=false&useUnbufferedInput=false&useReadAheadInput=false&maintainTimeStats=false&useServerPrepStmts&cacheRSMetadata=true"
min-idle: 30
max-idle: 30
max-total: -1
Expand Down
3 changes: 2 additions & 1 deletion toolset/setup/linux/frameworks/jester.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ cd jester
# 2015-06-25
git checkout 71b8cc069a0d271d619c2dc41bc6479047885587
nimble update
nimble install
# If /home/testrunner/.nimble/pkgs/jester exists, write over it.
echo 'y' | nimble install

echo "export JESTER_HOME=${JESTER}" > $IROOT/jester.installed

Expand Down
3 changes: 2 additions & 1 deletion toolset/setup/linux/languages/php.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ printf "\n" | $PHP_HOME/bin/pecl -q install -f yaf
# phalcon.so
# The configure seems broken, does not respect prefix. If you
# update the value of PATH then it finds the prefix from `which php`
git clone --depth=1 --branch=phalcon-v1.3.2 --single-branch \
git clone --depth=1 --branch=phalcon-v1.3.2 \
# This option doesn't work on older versions of git # --single-branch \
--quiet git://github.com/phalcon/cphalcon.git
cd cphalcon/build/64bits
$PHP_HOME/bin/phpize
Expand Down

0 comments on commit 9923de5

Please sign in to comment.