Skip to content

Instantly share code, notes, and snippets.

@makkaba
Created January 18, 2017 16:32
Show Gist options
  • Save makkaba/bb296f9c2ae7b58a55fcc6641f5dd134 to your computer and use it in GitHub Desktop.
Save makkaba/bb296f9c2ae7b58a55fcc6641f5dd134 to your computer and use it in GitHub Desktop.
node.js 헬로월드
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(8080, 'localhost');
console.log('Server running at http://localhost:8080/');
@makkaba
Copy link
Author

makkaba commented Jan 18, 2017

추가로 hello_express.js는 이렇게 테스트하면 되겠다.

var express = require('express')
var app = express()

app.get('/', function (req, res) {
  res.send('Hello Express')
})

app.listen(8080, function () {
  console.log('Example app listening on port 8080!')
})

!아마존 ec2를 사용한다면 8080포트가 다 열려있어야 함!

@makkaba
Copy link
Author

makkaba commented Feb 20, 2017

pm2 실행 (production mode)

NODE_ENV=production pm2 start app.js

@makkaba
Copy link
Author

makkaba commented Mar 15, 2017

이렇게 해도 된다
config.yml

apps:
  - script : index.js
    watch  : true
    env    :
      NODE_ENV: production
    env_production:
      NODE_ENV: production

pm2 start config.yml

@makkaba
Copy link
Author

makkaba commented Mar 15, 2017

시스템 리부팅 시에도 pm2 프로세스가 작동되도록 하려면
pm2 startup 명령어를 마지막에 쳐줘야 함

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment