reconfigured env variables and mysql connection

This commit is contained in:
bill bittner 2017-09-12 17:59:55 -07:00
parent 07f22eed3d
commit 59c2bf6c3c
4 changed files with 18 additions and 11 deletions

View file

@ -5,8 +5,7 @@ spee.ch is a single-serving site that reads and publishes images and videos to a
* start mysql * start mysql
* install mysql * install mysql
* create a database called `lbry` * create a database called `lbry`
* save your connection uri somewhere handy (you will need it when you start the server) * save your connection `username` and `password` someplace handy
* the uri should be in the form `mysql://user:pass@host:port/dbname`
* start lbrynet daemon * start lbrynet daemon
* install the [`lbry`](https://github.com/lbryio/lbry) daemon * install the [`lbry`](https://github.com/lbryio/lbry) daemon
* start the `lbry` daemon * start the `lbry` daemon
@ -17,10 +16,11 @@ spee.ch is a single-serving site that reads and publishes images and videos to a
* run `npm install` * run `npm install`
* to start the server, from your command line run `node speech.js` while passing three environmental variables: * to start the server, from your command line run `node speech.js` while passing three environmental variables:
* (1) your lbry wallet address (`LBRY_CLAIM_ADDRESS`), * (1) your lbry wallet address (`LBRY_CLAIM_ADDRESS`),
* (2) your mysql connection uri (`MYSQL_CONNECTION_STRING`), * (2) your mysql username (`MYSQL_USERNAME`),
* (2) your mysql password (`MYSQL_PASSWORD`),
* (3) the environment to run (`NODE_ENV`). * (3) the environment to run (`NODE_ENV`).
* i.e. `LBRY_CLAIM_ADDRESS=<your wallet address here> MYSQL_CONNECTION_STRING=<your connection uri here> NODE_ENV=development node speech.js` * i.e. `LBRY_CLAIM_ADDRESS=<your wallet address here> MYSQL_USERNAME=<username here> MYSQL_PASSWORD=<password here> NODE_ENV=development node speech.js`
* e.g. `LBRY_CLAIM_ADDRESS=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX MYSQL_CONNECTION_STRING=mysql://root:XXXXXX@localhost:3306/lbry NODE_ENV=development node speech.js` * e.g. `LBRY_CLAIM_ADDRESS=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX MYSQL_USERNAME="lbry" MYSQL_PASSWORD="xxxxxx" NODE_ENV=development node speech.js`
* To run hot, use `nodemon` instead of `node` * To run hot, use `nodemon` instead of `node`
* visit [localhost:3000](http://localhost:3000) * visit [localhost:3000](http://localhost:3000)

View file

@ -3,6 +3,7 @@
"LbryClaimAddress": "LBRY_CLAIM_ADDRESS" "LbryClaimAddress": "LBRY_CLAIM_ADDRESS"
}, },
"Database": { "Database": {
"MySqlConnectionUri": "MYSQL_CONNECTION_STRING" "username": "MYSQL_USERNAME",
"password": "MYSQL_PASSWORD"
} }
} }

View file

@ -6,7 +6,9 @@
"GoogleId": "none" "GoogleId": "none"
}, },
"Database": { "Database": {
"MySqlConnectionUri": "none" "database": "lbry",
"username": "none",
"password": "none"
}, },
"Logging": { "Logging": {
"LogLevel": "none" "LogLevel": "none"

View file

@ -6,14 +6,18 @@ const config = require('config');
const db = {}; const db = {};
const logger = require('winston'); const logger = require('winston');
const connectionUri = config.get('Database.MySqlConnectionUri'); const database = config.get('Database.database');
const sequelize = new Sequelize(connectionUri, { const username = config.get('Database.username');
const password = config.get('Database.password');
const sequelize = new Sequelize(database, username, password, {
host : 'localhost',
dialect: 'mysql',
logging: false, logging: false,
pool : { pool : {
max : 5, max : 5,
min : 0, min : 0,
idle : 20000, idle : 10000,
acquire: 20000, acquire: 10000,
}, },
}); });