본문 바로가기

node

linux watcher limit on pm2 Error: ENOSPC: System limit for number of file watchers reached, watch '/home/foldername/abcrypto/static' #11406 Increasing the amount of inotify watchers watcher Error PM2 | at NodeFsHandler._addToNodeFs (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:620:21) PM2 | Error: ENOSPC: System limit for number of file watchers reached, watch '/home/ubuntu/project/nexus2/no.. 더보기
pm2 npm start Can pm2 run an 'npm start' script Pm2 log dateformat pm2 JSON(설정)으로 실행 Run pm2 npm pm2 start npm -- start ecosystem.config.js module.exports = { apps: [{ name: "utilservice", script: "./bin/www", instanses: "max", exec_mode: "cluster", env: { NODE_ENV: "production" }, log_date_format: "YYYY-MM-DD HH:mm:ss.SSS", error_file: "./logs/pm2-err.log", out_file: "./logs/pm2-out.log", combine_logs: true,.. 더보기
NPM Permission Error npm throws error without sudo NPM permission 문제 해결하기 npm i 설치 permission 에러 npm ERR! Error: EACCES, open '/Users/username/.npm/-/all/.cache.json' npm ERR! { [Error: EACCES, open '/Users/username/.npm/-/all/.cache.json'] npm ERR! errno: 3, npm ERR! code: 'EACCES', npm ERR! path: '/Users/username/.npm/-/all/.cache.json' } npm ERR! npm ERR! Please try running this command again as root/Administrato.. 더보기
jwtwebtoken JWT for node.js # https://www.npmjs.com/package/jsonwebtoken npm i jsonwebtoken npm i magic-globals npm i lodash // JWTService.js const jwt = require('jsonwebtoken'); const SECRET='secretkey'; module.exports = { issuer(payload, expiresIn){ try{ return jwt.sign(payload, SECRET, { expiresIn }); }catch(TokenExpiredError){ throw { code: 'E_TOKEN', name: TokenExpiredError.name.. 더보기
Sails Restful-api Tutorials Sails.js | Realtime MVC Framework for Node.js Sails Restful-api Tutorials sails v1.x Fast, Simple API Build Tutorials 더보기
Node.js helloWorld HTTP 트랜잭션 해부 - 서버생성Hello world 예제 - express Node.js var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.write('Hello World!'); res.end(); }).listen(1337); node app.js # other terminal ab -n 10000 -c 10 -k http://127.0.0.1:1337/ ..... Concurrency Level: 10 Time taken for tests: 0.766 seconds Complete requests: 10000 Failed re.. 더보기
node.js 64bit int buffer Node.js Buffer Module nodejs write 64bit unsigned integer to buffer Converting a double to an int in Javascript without rounding Node.js 에서 64bit INT형을 다루는 버퍼는 없다. 이를 해결하기 위해서 32bit INT와 >>(비트계산)을 이용해서 64bit INT형으로 사용한다. var i = 99999; var buf = new Buffer(8); // 8byte 64bit buffer 생성 buf.fill(0); // 0으로 채우고 buf.writeUInt32BE(i >> 8, 0); // 상위 bit 자리 이동. buf.writeUInt32BE(i & 0x00ff, 4); // 하위비트.. 더보기
Pm2 log dateformat Log management pm2 install pm2-logrotate pm2 start app.js --log-date-format 'DD-MM HH:mm:ss.SSS' { "apps": [ { { "script" : "echo.js", "error_file" : "err.log", "out_file" : "out.log", "merge_logs" : true, "log_date_format" : "YYYY-MM-DD HH:mm Z" } ] } pm2 set pm2-logrotate:max_size 100M; pm2 set pm2-logrotate:dateFormat YYYY-MM-DD_HH-mm-ss; pm2 set pm2-logrotate:rotateInterval '0 * * * *'; pm2 .. 더보기