codestates / codestates/BookDam

21.12.31 Error Handling

Open
#43 0 comments 0 reactions 1 assignee Claimed by @sangkwonkim View on GitHub
Complete
Dominant language
JavaScript
Stars
1
Forks
1
PR merge metrics
No merged PRs in 30d

Description

### 어떤 에러인가요?
1. EC2 생성 후 배포 자동화 설정 시 노드 버전에 따라 npm install 문제
2. 서버 배포 자동화 scripts 폴더 파일 작성 시 port 번호 입력 실수

### 에러 메시지
1. EC2 생성 후 배포 자동화 설정 시 노드 버전에 따라 npm install 문제
![img (1)](https://user-images.githubusercontent.com/74910004/147808715-ab53a2fb-cc54-4f52-aa38-10e274efcdd2.png)
![img (2)](https://user-images.githubusercontent.com/74910004/147808720-25867416-9641-4832-abf6-30738e2ad5a7.png)

2. 서버 배포 자동화 scripts 폴더 파일 작성 시 port 번호 입력 실수
![img (3)](https://user-images.githubusercontent.com/74910004/147808774-16f2732c-8253-4252-a27c-fc625184b018.png)
```js
// scripts/initialize.sh
#!/bin/bash
cd /home/ubuntu/BookDam/server
npm install
npm install pm2@latest -g
sudo apt-get update
sudo apt-get install authbind
sudo touch /etc/authbind/byport/80
sudo chown ubuntu /etc/authbind/byport/80
sudo chmod 755 /etc/authbind/byport/80
```
```js
// /server/app.js
const express = require('express')
const app = express()
const port = 4000
```

### 에러 핸들링 방법
- 핸들링 방법에 대해서 간단하게 기록해보세요.
1. EC2 생성 후 배포 자동화 설정 시 노드 버전에 따라 npm install 문제
```js
//node.js 업데이트 (3개의 명령어를 차례차례 입력하세요.)
sudo npm cache clean --force
sudo npm install -g n
sudo n stable
//npm 업데이트
sudo npm install -g npm
```
EC2 상에서 위의 코드를 입력함으로써 문제를 해결하여 정상적으로 npm install 할 수 있었습니다.

2. 서버 배포 자동화 scripts 폴더 파일 작성 시 port 번호 입력 실수
```js
// /server/app.js
const express = require('express')
const app = express()
const port = 80
```

### 에러 핸들링을 위해 참고한 레퍼런스 링크
1. EC2 생성 후 배포 자동화 설정 시 노드 버전에 따라 npm install 문제
[링크](https://kimce.tistory.com/11)

### 해결하는 중 발견한 점
1. EC2 상에서 cd /opt/codedeploy-agent/deployment-root/deployment-logs/codedeploy-agent-deployments.log 파일에서 기록되는 log 상 pm2 와 파일 외부의 pm2 와 별개인 점을 확인할 수 있었습니다.
![img (4)](https://user-images.githubusercontent.com/74910004/147809183-a23666cd-5855-4eb5-9bc8-240aba421e26.png)

### 느낌점
코드스테이츠 측에서 학습했던 걸 프로젝트에 반영할 때, 꼼꼼히 살피지 못해서 발생하는 에러가 반복되지 않도록 주의해야겠습니다.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.