✳️ 첨부 파일은 Visual Studio 2017 프로젝트 파일입니다.

Python_Windows_Service.7z
0.09MB

Python으로 제작한 프로그램을 Windows Service로 만드는 가장 확실한 방법 입니다. 

준비물 : 

1. nssm : https://nssm.cc/download

 

NSSM - the Non-Sucking Service Manager

NSSM - the Non-Sucking Service Manager Windows 10, Server 2016 and newer 2017-04-26: Users of Windows 10 Creators Update or newer should use prelease build 2.24-101 or any newer build to avoid an issue with services failing to start. If for some reason you

nssm.cc

➔ 테스트 Project 파일과 함께 첨부해 놓았으나 최신 버전이 필요하시면 위 링크에서 다운로드 하시면 됩니다.

 

Service 등록 절차

✔️ Python 예제 프로그램

#_*_ coding: utf-8 _*_
import os
import sys
import time
import logging
from datetime import datetime, timedelta

def init():
    current_directory = os.path.dirname(os.path.realpath(__file__)) # .py 파일 위치
    current_log_directory = os.path.join(current_directory, "Log")  # 생성할 로그 폴더
    try:
        if not os.path.exists(current_log_directory):   # 로그 폴더 존재여부 검사
            os.makedirs(current_log_directory)          # 폴더 생성
    except OSError:
        print('----------------- Error -----------------')
        return -1

    # 로그파일 설정
    now_date_str = datetime.now().strftime('%Y%m%d_%H%M%S') # 현재 시간을 파일명으로 사용
    errorlogfilename = os.path.join(current_log_directory , "Log_%s.log" % (now_date_str))  # 로그파일의 전체 경로

    # 로그파일 생성
    logging.basicConfig(
        filename=errorlogfilename, 
        level=logging.DEBUG, 
        format='[%(asctime)s][%(name)s][%(levelname)s] - %(message)s'
    )
    return 1

def main():

    # 1초마다 로그파일에 현재 시간을 기록
    for i in range(10):
        out_message = "Now Time : %s" % (datetime.now().strftime('%Y-%m-%d_%H:%M:%S'))
        logging.info("Now Time : %s" % (out_message))
        print("Now Time : %s" % (out_message))
        time.sleep(1)

    return

if __name__ == '__main__':
    if (init() >= 1):
        while True:
            main()
            time.sleep(10)  # 10초마다 main() 함수 실행
    else:
        print("Exit")

✔️ 관리자 권한으로 CMD를 실행하여 nssm이 보관된 폴더로 이동합니다.

✔️ nssm install [서비스명]을 입력합니다.

 

✔️ Path : Python 실행파일을 선택합니다. (Startup directory는 자동으로 채워집니다.)

     ex) C:\Users\kirum\AppData\Local\Programs\Python\Python39\python.exe

✔️ Arguments : xxxx.py 파일을 전체 경로를 입력합니다.

     ex) D:\T\Python_Windows_Service\Python_Windows_Service\Python_Windows_Service.py

✔️ Install service 클릭

 

✔️ 정상적으로 Service가 등록되었으며 시작/중지 모두 정상적으로 작동합니다.

Nifi 를 Windows Service로 등록 및 운용하는 방법입니다. 

Python Flask 프로그램의 경우도 동일한 방법으로 Service로 등록할 수 있습니다.

http://nssm.cc/

 

NSSM - the Non-Sucking Service Manager

NSSM - the Non-Sucking Service Manager nssm is a service helper which doesn't suck. srvany and other service helper programs suck because they don't handle failure of the application running as a service. If you use such a program you may see a service lis

nssm.cc

- 저장한 NSSM 압축 파일의 압축을 해제합니다.

 

Nifi 서비스 등록 방법

1. 관리자 권한으로 CMD를 실행

2.  nssm 설치폴더 에서 nssm install [서비스명] 형태로 실행

3. 설정화면이 표시되면 Path의 선택버튼을 눌러 run-nifi.bat 파일을 선택

4. Install service 버튼을 눌러 서비스 등록 완료

5. 서비스 등록 확인

6. 서비스 관리자 에서는 nssm.exe를 실행하는것으로 보이지만 [레지스트리 편집기]를 보시면 nssm에 파라메터를 등록하여 nifi를 실행하고 있는것을 확인할 수 있습니다.

PC 재시작 / 서비스관리자를 통한 서비스 실행/중지 모두 정상적으로 동작하는것을 확인하였습니다.

 

Python Flask 웹 프로그램의 경우도 Python 파일을 실행하도록 xxx.bat 파일을 만들고

nssm으로 해당 xxx.bat 파일을 실행하도록 등록하면 됩니다.

'기타' 카테고리의 다른 글

[배터리] 18650 vs 14500 규격(사이즈)  (0) 2023.03.12
[가죽] 프레스  (0) 2023.03.10
Zotac egpu 와 2018 LG gram 연결 정보  (0) 2021.01.08
마우스 스위치 모음  (0) 2020.02.15
MAC PowerPoint 및 Word 의 탭 간격 조정 방법  (0) 2016.02.26

레드마인의 검색 기능에서 검색된 결과들은 클릭시 동일 탭에서 표시됩니다.

일반 일감의 경우는 크게 상관이 없으나 

보통 검색 작업은 검색 -> 항목 클릭 -> 내용 확인 -> 다른 검색 결과 항목 클릭 -> 내용 확인을

반복하게 되는데 이때 항목을 클릭했을 때 내용이 별도 탭으로 표시되면

재 검색하는 시간이 감소 합니다.

우클릭 / [새 탭에서 링크 열기] 메뉴를 사용해도 되지만 이를 깜박 잊고 클릭하게 되면 검색 페이지를 벗어났기 때문에

뒤로 가기로 검색시 첫 페이지 부터 표시되는 불상사가 발생합니다.

 

아래와 같이 레드마인 소스를 수정 및 적용하게 되면 검색 결과의 모든 링크는 

클릭시 자동으로 별도 탭에 표시 됩니다. 

 

- 레드마인 : 4.2.3 버전을 기준으로 설명 드립니다. (다른 버전도 파일명 위치 등이 비슷하기 때문에 이 글을 참고로 쉽게 수정하실 수 있습니다.)

- 레드마인의 설치 경로는 C:\Bitnami\redmine-4.2.3-3 라고 가정하겠습니다. 

1. C:\Bitnami\redmine-4.2.3-3\apps\redmine\htdocs\app\views\search\index.html.erb  파일을 메모장으로 열어

2.  link_to 함수에 아래와 같이 , :target => "_blank" 키워드를 추가 합니다.

<% if @results %>
    <div id="search-results-counts">
      <%= render_results_by_type(@result_count_by_type) unless @scope.size == 1 %>
    </div>
    <h3><%= l(:label_result_plural) %> (<%= @result_count %>)</h3>
    <dl id="search-results">
      <% @results.each do |e| %>
        <dt class="<%= e.event_type %> icon icon-<%= e.event_type %>">
          <%= content_tag('span', e.project, :class => 'project') unless @project == e.project %>
          <%= link_to(highlight_tokens(e.event_title.truncate(255), @tokens), e.event_url, :target => "_blank") %>
        </dt>
        <dd><span class="description"><%= highlight_tokens(e.event_description, @tokens) %></span>
        <span class="author"><%= format_time(e.event_datetime) %></span></dd>
      <% end %>
    </dl>
<% end %>

3.  redmineThin 서비스 2개를 모두 재시작 합니다.

4. 검색 결과에 target="_blank" 키워드가 추가된것이 보입니다.

 

5. 이제 검색된 결과의 항목을 클릭하게 되면 별도 탭으로 해당 게시물이 열립니다.

Tencent 공식 문서 : https://tendbcluster.net/book-en/

설치 필요 사항

(1) Docker 설치

  1. yum 패키지 업데이트

      $ yum -y update

  2. yum-utils 설치

      $ sudo yum install -y yum-utils

  3. Docker 저장소 등록

      $ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

  4. Docker 버전 조회

      $ yum list docker-ce --showduplicates | sort -r

  5. 특정 버전의 Docker 설치

      $ sudo yum install docker-ce-20.10.7-3.el7 docker-ce-cli-20.10.7-3.el7 containerd.io

  6. 버전 확인

      $ docker --version

  7. 서비스 시작

      $ systemctl start docker

      $ systemctl enable docker

      $ systemctl status docker

 

(2) Docker-compose 설치

  1. 설치 버전 확인

      https://github.com/docker/compose/tags

      https://github.com/docker/compose/releases/tag/1.27.4

  2. usr/local/bin 폴더에 다운로드

  $ sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

  3. 실행 권한 부여

      $ sudo chmod +x /usr/local/bin/docker-compose

  4. 심볼링링크 설정
      $ sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

  5. 버전 확인

      $ docker-compose --version

(3) helm 설치

  1. 설치할 버전 확인

      https://github.com/helm/helm/releases?page=3

  2. 다운로드

      $ wget https://get.helm.sh/helm-v2.17.0-linux-amd64.tar.gz

  3. 압축 해제

      $ tar xvzf helm-v2.17.0-linux-amd64.tar.gz

  4. 파일 이동

      $ sudo cp linux-amd64/tiller /usr/local/bin

      $ sudo cp linux-amd64/helm /usr/local/bin

  5. 권한 설정

      $ sudo chown root:docker /usr/local/bin/tiller

      $ sudo chown root:docker /usr/local/bin/helm

  6. 심볼릭 링크 설정
      $ sudo ln -s /usr/local/bin/helm /usr/bin/helm
      $ sudo ln -s /usr/local/bin/tiller /usr/bin/tiller

 

  7. 버전 확인

      $ helm version

      $ tiller --version

 

(4) Tendbcluster 도커 설치

  1. 환경설정파일 다운로드

      $ sudo curl -L "https://github.com/TenDBCluster/TenDBCluster-DockerCompose/archive/refs/heads/master.zip" -o tendbcluster-docker-compose.zip

  2. 압축 해제

      $ unzip tendbcluster-docker-compose.zip

  3. 폴더명 변경

      $ mv TenDBCluster-DockerCompose-master/ tendbcluster-docker-compose/

  4. Docker 이미지 다운로드

      $ cd tendbcluster-docker-compose && docker-compose pull

  5. 이미지 마운트

      $ docker-compose up -d

  6. 상태 조회

      $ docker ps -a

  7. 노란색 영역의 Port 번호로 MySQL 접속 테스트 

 

✳️ Tspider 가 설치된 CentOS 7 이미지 공유(VmWare)

OS : CentOS7OS

접속 정보 : root / Qwer1234!@#$ , tspider / Qwer1234!@#$

Tspider 접속 정보 : tendbcluster / tendbclusterpass

Google Drive : https://drive.google.com/file/d/17AnTdSycpYfAJDCXOF2uz_XwwZQXeDqL/view?usp=sharing

파일 용량 정보 : 

  - 압축 : 2.5 GB

  - 압죽 해제 : 10.9 GB

'Database & Data > Tspider' 카테고리의 다른 글

(1) 텐센트의 TSpider 소개  (2) 2021.01.03

데이터를 모으고 DB화하여 공유하는게 취미 입니다.

이번에는 다음 사이트에서 확인 가능한 대한민국 환율정보를 모아봤습니다.

✳️ MySQL DB에 저장 후 백업 파일로 공유드립니다.

https://finance.daum.net/exchanges/FRX.KRWUSD

 

 

환율 상세 | 다음 금융

 

finance.daum.net

✅ 일자별 환율 정보를 DB에 저장

 

✅ 대상 국가

currencyCode item_count min_date max_date nation_name
AED 3837 2006-01-02 2021-06-18 아랍에미리트
AUD 3837 2006-01-02 2021-06-18 호주
BDT 3837 2006-01-02 2021-06-18 방글라데시
BHD 3837 2006-01-02 2021-06-18 바레인
BND 3837 2006-01-02 2021-06-18 브루나이
BRL 3806 2006-01-02 2021-06-18 브라질
CAD 3817 2006-01-02 2021-06-18 캐나다
CHF 3837 2006-01-02 2021-06-18 스위스
CNY 3827 2006-01-02 2021-06-18 중국
CZK 1884 2013-11-01 2021-06-18 체코
DKK 3820 2006-01-02 2021-06-18 덴마크
EGP 3837 2006-01-02 2021-06-18 이집트
EUR 3837 2006-01-02 2021-06-18 유로
GBP 3836 2006-01-02 2021-06-18 영국
HKD 3837 2006-01-02 2021-06-18 홍콩
HUF 3311 2007-06-01 2021-06-18 헝가리
IDR 3837 2006-01-02 2021-06-18 인도네시아
ILS 3673 2006-01-02 2021-06-18 이스라엘
INR 3817 2006-01-02 2021-06-18 인도
JOD 3653 2006-01-02 2021-06-18 요르단
JPY 3837 2006-01-02 2021-06-18 일본
KWD 3837 2006-01-02 2021-06-18 쿠웨이트
KZT 1884 2013-11-01 2021-06-18 카자흐스탄
MNT 1884 2013-11-01 2021-06-18 몽골
MXN 3837 2006-01-02 2021-06-18 멕시코
MYR 3830 2006-01-02 2021-06-18 말레이시아
NOK 3837 2006-01-02 2021-06-18 노르웨이
NZD 3830 2006-01-02 2021-06-18 뉴질랜드
PHP 3837 2006-01-02 2021-06-18 필리핀
PKR 3827 2006-01-02 2021-06-18 파키스탄
PLN 3321 2007-06-01 2021-06-18 폴란드
QAR 1884 2013-11-01 2021-06-18 카타르
RUB 3462 2006-11-08 2021-06-18 러시아
SAR 3837 2006-01-02 2021-06-18 사우디
SEK 3837 2006-01-02 2021-06-18 스웨덴
SGD 3837 2006-01-02 2021-06-18 싱가포르
THB 3837 2006-01-02 2021-06-18 태국
TRY 1884 2013-11-01 2021-06-18 터키
TWD 3816 2006-01-02 2021-06-18 대만
USD 3837 2006-01-02 2021-06-18 미국
VND 3485 2006-09-29 2021-06-18 베트남
ZAR 3455 2006-11-17 2021-06-18 남아공

✅ 기간 : 2006-01-02 ~ 2021-06-18

✅ MySQL 백업 파일

db_exchange_rate_backup_20210619.7z
2.61MB

DataGrip 을 사용하다 보면 다양한 편의성 및 기능으로 인해 편리한 경우도 있지만, 의외로 불편한 경우도 많습니다. 

sp/함수 인자의 이름이 표시되는 아래 기능이 그런 경우가 아닐까 싶습니다. 

우측 설정시/비 설정시 이미지를 보시고 어떤 기능인지 확인해 보시면 될것 같습니다. 

기본은 활성화 입니다.

+ Recent posts