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

1010월/18

Android Chrome Inspect with Developer

종종 android 폰에서 크롬 디버깅이 필요할때가 있다. 1. 우선, adb가 개발 pc에 설치되어있지 않다면 아래 adb fastboot 을 다운로드받아 간편하게 설치해보자. https://forum.xda-developers.com/showthread.php?t=2317790 설치 후 콘솔에서 adb start-server adb kill-server 바로 adb 사용이 가능하다.   2. 그다음, 연결하고자 하는 스마트폰의 usb드라이버를 최신으로 설치한다. LG G6의 경우, LGMobileDriver_WHQL_Ver_4.2.0.exe 를 설치한다.   3. 스마트폰은 당연히 USB debugging 이 ON 되어야 한다. LG G6의 경우, 설정 > 시스템 > 휴대폰정보 > 소프트웨어 정보 > 빌드 번호 연속터치 그러면 개발자 모드가 열리게 되고, 그안에서 USB debugging을 ON 한다.   4. 이제 PC에서 크롬을 열고, chrome://inspect/#devices 에 접속한다. LGM-G600S 가 remote target에 추가되었다. 스마트폰의 크롬탭이 모두 보이게 되고, 해당 inspect 를 클릭하면, 디버깅에 유용하다.  

076월/18

ubuntu rsync

테스트서버에서 실서버로의 sync가 필요했다. 고민할것도 없이 rsync를 셋팅한다. 일단 rsync가 활성화되있는지 확인 #systemctl list-unit-files | grep rsync enable안되어 있다면 #sudo systemctl enable rsync.service 재부팅시에도 시작되게.. #update-rc.d rsync enable CENTOS의 경우에 재부팅시 시작은.. #systemctl enable rsyncd.service => Created symlink from /etc/systemd/system/… ~~ 나오면 정상 참고로 제거는.. #update-rs.d -f rsync remove rsync사용을 위한 xinetd 설치 #apt-get install xinetd 그리고 rsync서비스 작성 #vi /etc/xinetd.d/rsync service rsync { disable = no socket_type = stream wait = no user = root server = /usr/bin/rsync server_args = –daemon log_on_failure += USERID } #service xinetd restart 소스 경로 작성(들어올 부분) #vi /etc/rsyncd.conf [test_source] path=/home/tester/ comment=test_source uid=tester gid=tester use chroot=yes read only=no write only=yes hosts allow=허용IP max connections=15 timeout=300 rsync gogo #/usr/bin/rsync -av –exclude=.git –exclude=.gitattributes –exclude=.gitignore –delete /home/tester/ www.bluebee.co.kr::tester_source >> /home/tester/log/rsync.log 2>&1 소스가 실서버로 착착착~

046월/18

git pull after push

아무래도 git push 이후에 즉각 웹서비스를 올려야겠다. hook을 이용하여 push 를 하도록 한다. #mkdir /var/opt/gitlab/git-data/repositories/…/….git/custom_hooks #cd /var/opt/gitlab/git-data/repositories/…/….git/custom_hooks #vi post-receive #!/bin/sh cd /home/html/web/ || exit unset GIT_DIR git pull origin master exec git-update-server-info exit 0 #chmod +x pre-receive #chown git.git pre-receive 이제 git에 push작업 끝나면 custom hook이 발생하여 post-receive에 작성해둔 명령어를 실행하게 된다.   참고) git, dev서버 – user : git, group : 알아서 live, www서버 – user : 알아서, group : 알아서