./letsencrypt-auto certonly -w /home/ubuntu/date -d 도메인주소

 

2번 renew 선택

'nodejs' 카테고리의 다른 글

nvm alias default 6.1.0  (0) 2018.08.19
서버 세팅  (0) 2018.06.20
디버그 with development  (0) 2018.06.19
pm2.json 파일 실행  (0) 2018.04.19
pm2 node.js 버전 업데이트  (0) 2018.03.26
nvm alias default 6.1.0


'nodejs' 카테고리의 다른 글

letsencrypyt 인증서 갱신  (0) 2019.05.27
서버 세팅  (0) 2018.06.20
디버그 with development  (0) 2018.06.19
pm2.json 파일 실행  (0) 2018.04.19
pm2 node.js 버전 업데이트  (0) 2018.03.26


----------------------------------------------- 서버 시작시 mysql 세팅 ----------------------------------------------


Host is blocked because of many connection errors; unblock with \'mysqladmin flush-hosts\'


1. flush-hosts

    mysqladmin -u root -p flush-hosts


2. sudo mysql -u root -p

    mysql> set global max_connections=999999;

    mysql> set global max_connect_errors=999999;

    mysql> show variables like '%max_connect%';


3. 접속자수 조회


    mysql> show status like '%CONNECT%';


    +--------------------------+-------+

    | Variable_name            | Value |

    +--------------------------+-------+

    | Aborted_connects         | 200   |

    | Connections              | 300   |

    | Max_used_connections     | 101   |   ==> 현재 연결된 접속수

    | Ssl_client_connects      | 0     |

    | Ssl_connect_renegotiates | 0     |

    | Ssl_finished_connects    | 0     |

    | Threads_connected        | 101   |   ==> 연결되었던 최대 접속수

    +--------------------------+-------+


----------------------------------------------- https 서버 80 포트 deny ----------------------------------------------


sudo setcap 'cap_net_bind_service=+ep' /home/ubuntu/.nvm/versions/node/v8.11.1/bin/node

sudo setcap 'cap_net_bind_service=+ep' `which node`



----------------------------------------------- mysql log  ----------------------------------------------


mysql/lib/Connection.js 204 라인 추가


console.log(query.sql);


----------------------------------------------- ubuntu timezone 변경 ---------------------------------------


sudo ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime



----------------------------------------------- node mode 변경 ---------------------------------------

윈도

set NODE_ENV=production

set NODE_ENV=development


linux

export NODE_ENV=production

export NODE_ENV=development



----------------------------------------------- aws instance 변경 ---------------------------------------


1. 이미지로부터 instance 생성


2. 인스턴스 elastic ip 연결 해제


3. 탄력적 ip - 인스턴스 연결


4. 대상그룹 생성


5. 로드 발란서 생성


6. Route 53 - A 레코드 삭제 


7. 레코드셋 추가 


8. ssh 접속후 pm2 start



----------------------------------------------- aws 소스 반영 ---------------------------------------


1. origin instance 에 소스 업로드


2. 이미지 생성


3. 이미지로부터 instance 생성

'nodejs' 카테고리의 다른 글

letsencrypyt 인증서 갱신  (0) 2019.05.27
nvm alias default 6.1.0  (0) 2018.08.19
디버그 with development  (0) 2018.06.19
pm2.json 파일 실행  (0) 2018.04.19
pm2 node.js 버전 업데이트  (0) 2018.03.26
  1. Updated launch.json as follows:
{
    "version": "0.2.0",
    "configurations": [
        {
            "env": {
                "NODE_ENV": "development"
            },
        },


'nodejs' 카테고리의 다른 글

nvm alias default 6.1.0  (0) 2018.08.19
서버 세팅  (0) 2018.06.20
pm2.json 파일 실행  (0) 2018.04.19
pm2 node.js 버전 업데이트  (0) 2018.03.26
pm2 로그보기  (0) 2018.02.26
{
"apps": [{
"name": "coupon",
"script": "app.js",
"interpreter" : "node@8.10.0",
"watch": false,
"env": {
"NODE_ENV": "production",
"API_PORT":80
},
"exec_mode": "cluster",
"instances": 0
}]
}



pm2 start pm2.json


'nodejs' 카테고리의 다른 글

서버 세팅  (0) 2018.06.20
디버그 with development  (0) 2018.06.19
pm2 node.js 버전 업데이트  (0) 2018.03.26
pm2 로그보기  (0) 2018.02.26
pm2  (0) 2018.02.22

sudo npm install pm2@latest -g ; pm2 update


'nodejs' 카테고리의 다른 글

디버그 with development  (0) 2018.06.19
pm2.json 파일 실행  (0) 2018.04.19
pm2 로그보기  (0) 2018.02.26
pm2  (0) 2018.02.22
우분투 node 설치  (0) 2017.11.17

sudo pm2 monit


sudo pm2 show 0


tail -f /home/coupon/.pm2/logs/app-out-0.log



'nodejs' 카테고리의 다른 글

pm2.json 파일 실행  (0) 2018.04.19
pm2 node.js 버전 업데이트  (0) 2018.03.26
pm2  (0) 2018.02.22
우분투 node 설치  (0) 2017.11.17
KILL PID  (0) 2017.11.15

pm2 start app.js --name "test"

pm2 list

pm2 show <name>

pm2 restart <name>

pm2 logs <name>

pm2 plush

pm2 reload <name>

pm2 monit


클러스터 실행

pm2 start app.js -i 0 --name "test"

'nodejs' 카테고리의 다른 글

pm2 node.js 버전 업데이트  (0) 2018.03.26
pm2 로그보기  (0) 2018.02.26
우분투 node 설치  (0) 2017.11.17
KILL PID  (0) 2017.11.15
node 죽이기  (0) 2017.10.03
1. nvm 설치

  • curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash


2. nvm install v8.9.1

3. nvm use v8.9.1




'nodejs' 카테고리의 다른 글

pm2 로그보기  (0) 2018.02.26
pm2  (0) 2018.02.22
KILL PID  (0) 2017.11.15
node 죽이기  (0) 2017.10.03
ejs  (0) 2017.09.28

윈도우에서 


pm2 start start.js


taskkill /f /pid 13076

'nodejs' 카테고리의 다른 글

pm2  (0) 2018.02.22
우분투 node 설치  (0) 2017.11.17
node 죽이기  (0) 2017.10.03
ejs  (0) 2017.09.28
async  (0) 2017.09.20

윈도 : taskkill /F /IM node.exe


리눅스 : killall node


맥 :  sudo killall node



'nodejs' 카테고리의 다른 글

우분투 node 설치  (0) 2017.11.17
KILL PID  (0) 2017.11.15
ejs  (0) 2017.09.28
async  (0) 2017.09.20
미들웨어  (0) 2017.09.14

var fs = require('fs');


fs.readFile('ejsPage.ejs', 'utf-8', function(error, data){

response.writeHead(200, {'Content-Type': 'text-html'});

response.end(ejs.render(data));

});

'nodejs' 카테고리의 다른 글

KILL PID  (0) 2017.11.15
node 죽이기  (0) 2017.10.03
async  (0) 2017.09.20
미들웨어  (0) 2017.09.14
npm start  (0) 2017.09.13

var async = require('async');


var files = ['Txt1.txt', 'Txt2.txt','Txt3.txt'];


async.forEach(files, function(item, index){

console.log(item);

});


async.map(files, fs.readFile, function(error , results){

console.log(results);

});


//순차실행

async.series([

function (callback){

console.log("11111111");

callback(null, 1);

},
function(callback){

console.log("22222222");

callback(null, 2);

}

], function(error, result){

console.log("333333", result);

});



//동시실행

async.parallel([

function (callback){

console.log("11111111");

callback(null, 1);

},
function(callback){

console.log("22222222");

callback(null, 2);

}

], function(error, result){

console.log("333333", result);

});


460 P 참고



'nodejs' 카테고리의 다른 글

node 죽이기  (0) 2017.10.03
ejs  (0) 2017.09.28
미들웨어  (0) 2017.09.14
npm start  (0) 2017.09.13
nvm 설치  (0) 2017.09.12

클라이언트에서 요청시 로그를 남기는 간단한 기능을 함수로 만든후 use() 메서드를 사용해 미들웨어로 등록해 두면 모든 클라이언트 요청이 이 미들웨어를 거치면서 로그를 남기게 된다. 


각각의 미들웨어는 next() 메서드를 호출하여 다음 미들웨어가 처리할수 있도록 순서를 넘길수 있다.

'nodejs' 카테고리의 다른 글

ejs  (0) 2017.09.28
async  (0) 2017.09.20
npm start  (0) 2017.09.13
nvm 설치  (0) 2017.09.12
express  (0) 2017.05.26

package.json 파일의 start 속성에 적힌 명령이 실행

'nodejs' 카테고리의 다른 글

async  (0) 2017.09.20
미들웨어  (0) 2017.09.14
nvm 설치  (0) 2017.09.12
express  (0) 2017.05.26
DummyDB  (0) 2017.05.26

1. nvm windows 설치


2. nvm install 버전 (node 설치)


3.nvm use 버전



'nodejs' 카테고리의 다른 글

미들웨어  (0) 2017.09.14
npm start  (0) 2017.09.13
express  (0) 2017.05.26
DummyDB  (0) 2017.05.26
nodemon  (0) 2017.02.27

npm install -g express-generator@4


express projectName


cd projectName && npm install


SET DEBUG=projectName:* & npm start

http://127.0.0.1:3000

'nodejs' 카테고리의 다른 글

npm start  (0) 2017.09.13
nvm 설치  (0) 2017.09.12
DummyDB  (0) 2017.05.26
nodemon  (0) 2017.02.27
파일 경로  (0) 2017.02.27

var DummyDB = (function(){

var DummyDB = {};

var storage = [];

var count = 1;


DummyDB.get = function(id){

if(id){

id = (type of == 'string') ? Number(id) : id;


for(var i in storage)

{

if(storage[i].id == id)}

return storage[i];

}

else{

return storage;

}

}

}

});


DummyDB.insert = function(id){

data.id = count++;

storage.push(data);

return data;

});


DummyDB.remove = function(id){

id = (typeof id == 'string') ? Number(id) : id;


for(var i  inn storage) if(storage[i].id == id){

storage.splice(i,1);


return true;

}


return false;


});


return DummyDB;

})();

'nodejs' 카테고리의 다른 글

nvm 설치  (0) 2017.09.12
express  (0) 2017.05.26
nodemon  (0) 2017.02.27
파일 경로  (0) 2017.02.27
예외 발생시 node crash 시키지 않기  (0) 2017.02.27

자동업데이트

npm install -g nodemon


nodemon app.js



'nodejs' 카테고리의 다른 글

express  (0) 2017.05.26
DummyDB  (0) 2017.05.26
파일 경로  (0) 2017.02.27
예외 발생시 node crash 시키지 않기  (0) 2017.02.27
커스텀 이벤트, 상속  (0) 2017.02.27

var pathUtil = requier("path");


전역객체

__filename

__dirname

같은 폴더내 이미지경로

var path = __dirname + "/image.png";

경로다듬기

path.normalize();

pathUtil.normalize("/user/tmp/../local////bin/");

=>return  /user/local/bin/

요소얻기

var path = "/foo/bar/static/loading.png"

path.basename() //파일명 : loading.png

path.dirname() //폴더경로 : /foo/bar/static

path.extname() //확장자 : .png

경로 구성 객체

var info = path.parse("/home/user/dir/file.txt");

console.log(info);

경로만들기

__dirname + pathUtil.sep + "image.png"; // 현재폴더내 image.png

pathUtil.join("/foo","bar","baz/asdf","quux","..")    // (경로붙이기) return "/foo/bar/baz/asdf

var path = pathUtil.format({    //return "/home/user/dir/file.txt"

root:"/",

dir:"/home/user/dir",

base:"file.txt",

ext:".txt",

name:"file"

});



'nodejs' 카테고리의 다른 글

DummyDB  (0) 2017.05.26
nodemon  (0) 2017.02.27
예외 발생시 node crash 시키지 않기  (0) 2017.02.27
커스텀 이벤트, 상속  (0) 2017.02.27
util 모듈  (0) 2017.02.27

process.on("uncaughtException",function(code){

console.log("uncaughtException");

});


sayHello();

'nodejs' 카테고리의 다른 글

nodemon  (0) 2017.02.27
파일 경로  (0) 2017.02.27
커스텀 이벤트, 상속  (0) 2017.02.27
util 모듈  (0) 2017.02.27
log  (0) 2017.02.27

var customEvent = new event.EventEmitter();


customEvent.on("tick", function(){

console.log("custom event");

});


customEvent.emit("tick");


======================================

클래스에 이벤트를 발생시크고 싶을 경우 EventEmitter 를 상속한다.

var Person = function();

//상속

var util = require("util");

var EventEmitter = require("event").EventEmitter;

util.inherits(Person, EventEmitter);

//객체

var p = new Person();

p.on("howAreYou", function(){

console.log("Fine Thank you and you");

});

//이벤트밸생

p.emit("howAreYou");

'nodejs' 카테고리의 다른 글

파일 경로  (0) 2017.02.27
예외 발생시 node crash 시키지 않기  (0) 2017.02.27
util 모듈  (0) 2017.02.27
log  (0) 2017.02.27
Console  (0) 2017.02.27

var util = require("util");

var format = util.format("%d",1)

%d : 실수, %s : string, %j : json


function Parent(){

}

function Child(){

}

util.inherits(Child, Parent);

'nodejs' 카테고리의 다른 글

예외 발생시 node crash 시키지 않기  (0) 2017.02.27
커스텀 이벤트, 상속  (0) 2017.02.27
log  (0) 2017.02.27
Console  (0) 2017.02.27
사용자 정의 모듈  (0) 2012.03.16

var fs = require("fs");

var output = fs.createWriteStream("stdout.log");

var errorOutput = fs.createWriteStream("error.log");


var Console = require("console").Console;

var logger = new Console(output, errorOutput);


logger.info("info messge");

logger.log("log messge");


logger.warn("warning");

logger.error("error messge");

'nodejs' 카테고리의 다른 글

커스텀 이벤트, 상속  (0) 2017.02.27
util 모듈  (0) 2017.02.27
Console  (0) 2017.02.27
사용자 정의 모듈  (0) 2012.03.16
명령어  (0) 2012.03.16

console.time("sum");

...

console.timeEnd("sum");


var obj = {

name = "홍길동"

}

console.log("obj : " , obj);

'nodejs' 카테고리의 다른 글

커스텀 이벤트, 상속  (0) 2017.02.27
util 모듈  (0) 2017.02.27
log  (0) 2017.02.27
사용자 정의 모듈  (0) 2012.03.16
명령어  (0) 2012.03.16

---------------------------------- mymodule.js -----------------------
 
exports.abs = function (number) {
    if (0 < number) {
        return number;
    } else {
        return -number;
    }
};

exports.circleArea = function (radius) {
    return radius * radius * Math.PI;
};


-------------------------------- main.js ----------------------------------

var mymodule = require('./mymodule.js');


console.log('abs(-273) = %d', mymodule.abs(-273));
console.log('circleArea(3) = %d', mymodule.circleArea(3));

'nodejs' 카테고리의 다른 글

커스텀 이벤트, 상속  (0) 2017.02.27
util 모듈  (0) 2017.02.27
log  (0) 2017.02.27
Console  (0) 2017.02.27
명령어  (0) 2012.03.16
- 글로벌 설치목록
$ npm list -g

- 로컬 설치목록
$ npm list 

- 업데이트
$ npm update 모듈명

- 모듈삭제
$ npm uninstall 모듈명

 

'nodejs' 카테고리의 다른 글

커스텀 이벤트, 상속  (0) 2017.02.27
util 모듈  (0) 2017.02.27
log  (0) 2017.02.27
Console  (0) 2017.02.27
사용자 정의 모듈  (0) 2012.03.16

+ Recent posts