All posts by bluebee

024월/20

httpd 프로세스 누적 처리

httpd 프로세스가 누적되는 경우가 종종 있다. 특히 워드프레스.. 음 안쓰기도 뭐하고.. 무거운 워드프레스를 다 해집기 보다는.. 그냥 재시작 처리를 해두는게 나을지도 #!/bin/sh while ( true ) ; do if [ “`ps aux | grep httpd | wc -l`” -ge “50” ] ; then systemctl restart httpd date >> /home/engineer/shell/apache_auto_restart.log fi sleep 10 done 프로세스 수량 50은.. 봐가면서 변경

1012월/19

bootstrap datepicker language, format 설정

언어 설정 가이드 : https://bootstrap-datepicker.readthedocs.io/en/stable/i18n.html 한국어js : https://github.com/uxsolutions/bootstrap-datepicker/blob/master/dist/locales/bootstrap-datepicker.ko.min.js <script src=”/assets/js/bootstrap-datepicker.ko.min.js” charset=”UTF-8″></script> <script src=”/assets/js/bootstrap-datepicker.js” type=”text/javascript”></script> $(‘#date1’).datepicker({ format: ‘yyyy-mm-dd’, language: “ko” }

1311월/19

php 로그인, 크롤링 by Snoopy

간혹 업체의 report api가 구비되지 않아서 크롤링을 한다거나, 주기적인 업데이트를 위해 크롤링이 필요한 경우가 있다. 그와중에 로그인 후 크롤링을 할 경우까지 종종 등장한다. 이때 오래되었으나 snoopy 라이브러리를 이용하면 좋다. Snoopy download https://sourceforge.net/projects/snoopy/ 바로 import하여 사용한다. <?php require_once(‘lib/Snoopy.class.php’); $snoopy = new Snoopy; $snoopy->agent = “Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)”; //login $loginUri = ‘http://www.bluebee.co.kr/loginTest.php’; $snoopy->httpmethod = “POST”; $auth[‘id’] = ‘bluebee’; $auth[‘password’] = ‘1234’; $snoopy->submit($loginUri, $auth); $snoopy->setcookies(); //로그인에 쿠키를 사용하는 경우가 있으니 쿠키정보를 저장 $loginResult = json_decode($snoopy->results); $report_data = array(); if($loginResult->{‘ret’} != “ok”) { echo ‘Login 실패!’; exit; } else { //리포트 데이터 크롤링 $reportUri = ‘http://www.bluebee.co.kr/reportTest.php’; $snoopy->httpmethod = “POST”; $report[‘sdate’] = ‘2019-11-01’; $report[‘edate’] = ‘2019-11-13’; $snoopy->submit($reportUri, $report); preg_match(‘/<tr class=”reportR”>(.*?)<\/tr>/is’, $snoopy->results, $result_report_tr); if(sizeof($result_report_tr) > 1) { preg_match_all(‘/<td[^>]*>(.*?)<\/td>/is’, $result_report_tr[1], $result_report_td); /*데이터 정리*/ } } ?> 로그인이 필요한 경우 간편하게~ 대충 이런 형태로 간단하게 뽑아낼 수 있겠다.   오류 발생 대처 방법 PHP Deprecated: The each() function is deprecated. php버전에 따라 오류발생 가능 Snoopy.class.php 의 each 관련 사항을 모두 foreach로 수정 예) while (list($key, $val) = each($links[2])) { => foreach($links[2] as $key => $val) { 그외 딱히 이슈될건 없다.

189월/19

ubuntu, nginx, php 빈번한 셋팅 오류

서버 셋팅시 빈번히 발생하는 오류와 해결내용을 메모해두자. nginx 502 Bad Gateway upstream: “fastcgi://127.0.0.1:9000” sudo vi /etc/php/7.0/fpm/pool.d/www.conf ;listen = /run/php/php7.0-fpm.sock listen = 127.0.0.1:9000   access denied sudo vi /etc/php/7.0/fpm/pool.d/www.conf security.limit_extensions = .php .php3 .php4 .php5 .php7 .html sudo service php7.0-fpm restart nginx ssl_certificate_key pass 오류 원본 백업 cp domain.key domain.key.org 키의 password 입력 처리 openssl rsa -in domain.key.org -out domain.key sudo service nginx restart 스마트에디터 The uploaded file exceeds the post_max_size The uploaded file exceeds the post_max_size 오류 발생 php.ini 용량 설정이나 그누보드 어드민의 용량설정을 해봤자 스마트에디터 자체에 용량제한이 또 걸려있다. (어떤놈이 대체 이렇게..) /extend/smarteditor_upload_extend.php 를 열어서 수정하자. define(‘SMARTEDITOR_UPLOAD_SIZE_LIMIT’, 20); // 스마트에디터 업로드 사이즈 제한 ( 기본 20MB ) client intended to send too large body nginx 설정에서 적용해주자. server { client_max_body_size 0; }

037월/19

TensorFlow on Anaconda3 5.2.0

아나콘다 설치 : https://repo.continuum.io/archive/index.html Anaconda3-5.2.0-Windows-x86_64.exe (python 3.6.5) 관리자 권한으로 설치 후 확인 > conda –version conda 4.5.4 > python –version Python 3.6.5 :: Anaconda ,Inc.  Anaconda Prompt 관리자 실행 후 업데이트 > conda update -n base conda > conda update –all > python -m pip install –upgrade pip 아나콘다 가상환경 구성 > conda create -n bluebee1 python=3.6 > conda activate bluebee1 base로 돌아오려면.. > conda deactivate 가상환경에 TensorFlow 설치 > conda install tensorflow 설치확인 > python >>> import tensorflow as tf >>> tf.__version__ ‘1.13.1’ jupyter notebook ide설치 > conda install jupyter notebook 실행 > jupyter notebook 기본 브라주에서 실행되는것을 확인. 준비끝 jupyter notebook 기본 디렉터리 변경 설정파일 path 알아보기 > jupyter notebook –generate-config Writing default config to : 경로 해당 경로의 jupyter_notebook_config.py 열어서 수정 c.NotebookApp.notebook_dir = ” 항목에 디렉터리 지정 예) c.NotebookApp.notebook_dir = ‘D:/project/jupyter’

112월/19

android adb를 이용한 shell 접근

adb를 이용하여 기기에서의 shell 명령이 가능하다. 우선 디바이스 리스트를 가져오자. C:\Users\bluebee\AppData\Local\Android\Sdk\platform-tools>adb devices 그다음 기기에 shell을 아래와 같이 날린다. 예제는 기기의 알람 상황 살펴보기. adb -s devicename shell dumpsys alarm | find “bluebee” 이렇게 진행해도 되겠다. adb -s devicename shell run-as packagename

0811월/18

AWSome day online certificate

오랜만에 온라인 강좌(?)를 보았다. AWS 클라우드를 사용해볼까 하는 마음에서.. 이번 AWSome day 영상을 봤을때~ 도움받을 수 있는 내용이다. AWS의 핵심 서비스들에 대해 더욱 깊이 이해할 수 있습니다. AWS 클라우드에 인프라를 배포하고 자동화하는 법을 배울 수 있습니다. AWS에서 인증하는 Cloud Practitioner 시험 준비를 할 수 있습니다. AWS 전문가들에게 평소 궁금해 하던 것들을 물어보실 수 있습니다. 모든 강의를 다 듣고 나면 AWSome Day 참석 증명서를 받으실 수 있습니다. 이렇게해서 받은 증명서.. 음 이게 왜 필요하지? ^^;; 어쨋든 다음 프로젝트에서는 aws를 이용해보도록 하겠다. 발표자료 보기 : https://aws.amazon.com/ko/events/awsome-day/awsome-day-online/