Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // sequelize config
- var sequelize = new sequelize('database', 'user', 'pass', {
- host: '127.0.0.1',
- dialect: 'mysql',
- port: 3306,
- pool: {
- max: 10,
- min: 0,
- idle: 20000
- }
- });
- // tunnel config
- var config = {
- user:'user',
- host:'sshhost',
- port:22,
- dsthost:'127.0.0.1',
- dstport:3306,
- srchost:'127.0.0.1',
- srcport:3306,
- localhost:'127.0.0.1',
- localport: 3306,
- privatekey: require('fs').readfilesync('/path/to/key')
- };
- var tunnel = require('tunnel-ssh');
- // initiate tunnel
- tunnel(config, function (error, server) {
- //....
- if(error) {
- console.error(error);
- } else {
- console.log('server:', server);
- // test sequelize connection
- sequelize.authenticate().then(function(err) {
- console.log('connection established');
- }).catch(function(err) {
- console.error('unable establish connection', err);
- })
- }
- })
Add Comment
Please, Sign In to add comment