Merge pull request #12 from mozilla/mysql_kvstore

Purges couchbase and adds mysql setup and configuration
This commit is contained in:
Ryan Kelly 2013-04-09 17:43:00 -07:00
Родитель db25b09482 81f60aff61
Коммит 155de68d91
8 изменённых файлов: 63 добавлений и 70 удалений

Просмотреть файл

@ -3,6 +3,9 @@
"index.js"
],
"env": {
"CONFIG_FILES": "$HOME/code/config/aws.json,$HOME/kvstore.json,$HOME/config.json"
"CONFIG_FILES": "$HOME/code/config/aws.json,$HOME/config.json"
},
"remote_hooks": {
"postcreate": "scripts/aws/post_create.sh"
}
}

Просмотреть файл

@ -12,3 +12,11 @@ notifications:
- "irc.mozilla.org#picl"
use_notice: false
skip_join: false
env:
- KVSTORE_BACKEND=mysql
- KVSTORE_BACKEND=memory
before_script:
- "mysql -e 'DROP DATABASE IF EXISTS test;'"
- "mysql -e 'CREATE DATABASE test;'"

Просмотреть файл

@ -1,5 +1,8 @@
{
"kvstore": {
"backend": "couchbase"
"backend": "mysql"
},
"mysql": {
"database": "picl"
}
}

Просмотреть файл

@ -4,7 +4,7 @@
var convict = require('convict');
const AVAILABLE_BACKENDS = ["memory", "couchbase"];
const AVAILABLE_BACKENDS = ["memory", "mysql"];
var conf = module.exports = convict({
@ -23,6 +23,12 @@ var conf = module.exports = convict({
doc: "The audience we expect incoming assertions to use",
default: "https://firefox.com"
},
persona_url: {
doc: "Persona service",
format: "url",
default: "https://picl.personatest.org",
env: 'PERSONA_URL'
},
public_url: {
format: "url",
// the real url is set by awsbox
@ -45,20 +51,42 @@ var conf = module.exports = convict({
default: AVAILABLE_BACKENDS
}
},
couchbase: {
mysql: {
user: {
default: 'Administrator',
env: 'KVSTORE_USERNAME'
default: 'root',
env: 'MYSQL_USERNAME'
},
password: {
default: 'password',
env: 'KVSTORE_PASSWORD'
default: '',
env: 'MYSQL_PASSWORD'
},
bucket: {
database: {
default: 'picl',
env: 'KVSTORE_BUCKET'
env: 'MYSQL_DATABASE'
},
hosts: [ "localhost:8091" ]
host: {
default: '127.0.0.1',
env: 'MYSQL_HOST'
},
port: {
default: '3306',
env: 'MYSQL_PORT'
},
create_schema: {
default: true,
env: 'CREATE_MYSQL_SCHEMA'
},
max_query_time_ms: {
doc: "The maximum amount of time we'll allow a query to run before considering the database to be sick",
default: 5000,
format: 'duration',
env: 'MAX_QUERY_TIME_MS'
},
max_reconnect_attempts: {
doc: "The maximum number of times we'll attempt to reconnect to the database before failing all outstanding queries",
default: 3,
format: 'nat'
}
},
bind_to: {
host: {
@ -85,8 +113,8 @@ if (process.env.CONFIG_FILES) {
}
if (conf.get('env') === 'test') {
if (conf.get('kvstore.backend') === 'couchbase') {
conf.set('couchbase.bucket', 'default');
if (conf.get('kvstore.backend') === 'mysql') {
conf.set('mysql.database', 'test_keyserver');
}
}

Просмотреть файл

@ -20,9 +20,6 @@
"async": "0.1.22",
"node-uuid": "1.4.0"
},
"optionalDependencies": {
"couchbase": "0.0.11"
},
"devDependencies": {
"mocha": "1.8.1"
}

Просмотреть файл

@ -1,34 +0,0 @@
#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
var child_process = require('child_process');
function uploadScript (host, cb) {
var args = ['-o', 'StrictHostKeyChecking=no',
path.join(__dirname, 'install_couchbase.sh'),
'ec2-user@' + host + ':install_couchbase.sh' ];
var p = child_process.spawn('scp', args, {'stdio': 'inherit'});
p.on('exit', function(code, signal) {
var err = code || signal;
if (err && cb) return cb(err);
ssh('sh install_couchbase.sh');
});
function ssh(cmd) {
var args = ['-o', 'StrictHostKeyChecking=no',
'ec2-user@' + host, cmd];
var p = child_process.spawn('ssh', args, {'stdio': 'inherit'});
p.on('exit', function(code, signal) {
if (cb) cb(code || signal);
});
}
}
module.exports = uploadScript;
if (require.main === module)
uploadScript(process.argv[2]);

Просмотреть файл

@ -1,20 +0,0 @@
sudo wget -O/etc/yum.repos.d/couchbase.repo http://packages.couchbase.com/rpm/couchbase-centos62-x86_64.repo
sudo yum check-update && sudo yum install -y libcouchbase-devel
wget http://packages.couchbase.com/releases/2.0.0/couchbase-server-enterprise_x86_64_2.0.0.rpm
sudo yum install -y couchbase-server-enterprise_x86_64_2.0.0.rpm
sleep 15
PASS=`openssl rand -base64 16`
BUCKET=picl
/opt/couchbase/bin/couchbase-cli cluster-init -c 127.0.0.1:8091 --cluster-init-username=Administrator --cluster-init-password=$PASS --cluster-init-port=8091 --cluster-init-ramsize=1024
/opt/couchbase/bin/couchbase-cli bucket-create -c 127.0.0.1:8091 --bucket=$BUCKET --bucket-type=couchbase --bucket-ramsize=1024 --bucket-replica=0 -u Administrator -p $PASS
echo {\"couchbase\": {\"password\":\"${PASS}\", \"bucket\":\"${BUCKET}\"}} > kvstore.json
sudo mv kvstore.json /home/app/kvstore.json

8
scripts/aws/post_create.sh Executable file
Просмотреть файл

@ -0,0 +1,8 @@
#!/usr/bin/env bash
echo "Setting up mysql"
sudo /sbin/chkconfig mysqld on
sudo /sbin/service mysqld start
echo "CREATE USER 'picl'@'localhost';" | mysql -u root
echo "CREATE DATABASE picl;" | mysql -u root
echo "GRANT ALL ON picl.* TO 'picl'@'localhost';" | mysql -u root