TIL - 2021.1.27

Wanna be __·2021년 1월 27일
0

TIL

목록 보기
9/45
post-thumbnail

Today, I Learned

  1. Java Hashmap<K, V>
    String을 index로 사용할때 매우 유용
    Hashmap<String, Integer> hm = new Hashmap<>(); 일때
    hm.put([KEY], [VAL])으로 추가,
    hm.get([KEY])로 Value 얻음
    없는 key를 get했을때는 null값 return

  2. Hashmap의 Key에 따라 오름차순 정렬하는 방법
    Hashmap 자체를 정렬할 수는 없음 -> Key를 따로 뽑아서 정렬한뒤에, 그 키 순서대로 Hashmap을 호출하면 그게 곧 정렬임.

Object[] arr = hm.KeySet().toArray(); //이걸로 받고
Arrays.sort(arr); // 내장 패키지로 소팅후

for(Object it : arr){ // 향상된 for문 매우 유용
  hm.get(it);
}
  1. Java Formatter
    [문자열 소수넷째자리] 와 같이 표시하기 위하여 알아보던 중, Formatter 찾음
Formatter fm = new Formatter();

진짜 강력한 점은, Formatter 생성자 매개변수로 StringBuilder나 StringBuffer등을 넘겨주게 되면, 해당 StringBuilder, StringBuffer를 append 하여 문자열을 추가할 필요 없이, fm.format("%s %d\n", "문자열", 정수) 와 같이 formatter의 매서드를 사용함을 통하여 해당 StringBuilder, StringBuffer에 Format을 맞추어 추가할 수 있음.

  • 출력은 System.out.println(fm); <-- Formatter instance를 넣어준다

1,2,3 번을 통해 해결한 문제: 백준 4358

  1. Java TreeMap
    Hashmap과 사용방법은 같으나 자동정렬해서 넣어주는 대단한 놈..
Map<String, Integer> tm = new TreeMap<>();
  1. Docker image 한번에 삭제
    docker image prune -a

Today, I Did

오늘의 여정
Django + React + Nginx구조에서
1. Volume관련된 설정 모두 제거후 빌드
2. Frontend container제거후 빌드
3. Backend container제거후 빌드
4. react, nginx 공유 volume 위치 변경후 빌드
5. react, nginx 공유 volume dir 생성 후 빌드
6. Backend Container명 server에서 backend로 변경후 빌드
7. backend image에서 gunicorn은 자꾸 종료되고 이 때문에 여기 의존하고 있는 Nginx도 종료됨 -> backend image들어가서 gunicorn 작동 테스트
8. 아무것도 없는 상태에서 시작
9. nginx:latest, command "nginx", "-g", "daemon off;" 작성해서 배포 - 성공
10. nginx custom, django + gunicorn 작성 - 실패 (Hook/opt/elasticbeanstalk/hooks/appdeploy/enact/03start-task.sh failed.)
11. nginx custom, react + nginx 작성 - 실패 (Hook/opt/elasticbeanstalk/hooks/appdeploy/enact/03start-task.sh failed.)
12. 11번 nginx custom 파일 단독 빌드 - 실패 (Hook/opt/elasticbeanstalk/hooks/appdeploy/enact/03start-task.sh failed.)
13. 11번 nginx custom 파일에서 upstream 없애고 naver.com으로 빌드 - 성공 why? 의심되는 부분 1. upstream 설정된 host name 문제, 2. custom nginx의 Dockerfile 설정 문제
14. 13번의 2번 먼저 확인 -> 디렉토리 상대경로 typo 발견 -> ./ 추가하여 성공
15. 수정한 nginx custom 파일, react + nginx 작성 - 성공!

profile
성장하는 개발자

0개의 댓글