This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const mongoose = require('mongoose'); | |
mongoose.Promise = require('bluebird'); | |
module.exports = (config) => { | |
let options = { keepAlive: 300000 }; | |
if (process.env.NODE_ENV == 'production') { | |
options = { | |
server: { poolSize: 100, socketOptions: { keepAlive: 300000, connectTimeoutMS: 30000 } }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const mongoose = require('mongoose'); | |
mongoose.Promise = require('bluebird'); | |
module.exports = (config) => { | |
if (process.env.NODE_ENV === 'development') | |
mongoose.set('debug', true); | |
let options = { keepAlive: 300000 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class customDB { | |
constructor() { | |
this.models = {}; | |
this.readConnection = null; | |
// {model:collectionName} // this needed as collection names are not same as Model | |
this.model_list = { | |
'User':'users' | |
}; | |
} | |
async createConnection(app, config) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require("http"); | |
let keepAliveAgent = new http.Agent({ | |
keepAlive: true, | |
maxSockets: 5, | |
keepAliveMsecs: 60000 | |
}); | |
let name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require("http"); | |
const server = http.createServer((req,res)=>{ | |
console.log("request came", req.url); | |
// faking 1 sec amount of work | |
setTimeout(()=>{ | |
console.log("response sent", req.url); | |
res.writeHead(200, { 'Content-Type': 'text/plain' }); | |
res.end('okay'); | |
},1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Step-1: create git directory (/home/ubuntu/site.git). | |
$/home/ubuntu/site.git> git init --bare | |
Step-2: your deployment path (/home/ubuntu/www) from where site will be served. | |
Step-3: Inside site.git folder move to hooks folder and create a file named post-receive. | |
paste below code inside it. | |
#!/bin/bash | |
deploy="yes" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you accidentally deleted your server's ".ssh/authorized_keys" then follow below steps | |
# lost key instance => lost_ec2 | |
# new launched instance => new_ec2 | |
step 1: launch new ec2 instance and generate new .pem(new_pem.pem) file. | |
step 2: stop lost_ec2 instance and dettache volume. | |
step 3: attach lost_ec2 volume to new_ec2 volume. | |
step 4: log in to new_ec2 using new_pem.pem file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SETUP APACHE ON WINDOW | |
> Path can be different for your xampp server so look for file location accordingly. | |
**Step:1** C:/xampp/apache/conf/httpd.conf | |
Search for “proxy_http_module” and uncomment it. | |
**Step:2** C:/xampp/apache/conf/extra/httpd-vhosts.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
server { | |
listen 80; | |
server_name example2.com www.example2.com xyz.example.com; | |
location / { | |
proxy_set_header HOST $host; | |
proxy_set_header X-Forwarded-Proto $scheme; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Make life easier by aliasing daily used commands | |
### edit .bashrc file | |
Step 1:- Move to home directory by typing. | |
>CD | |
Step 2:- Open .bashrc file. | |
>vim .bashrc | |
or | |
>nano .bashrc |
NewerOlder