반응형

파일명 혹은 변수에 '-'가 제거된 날짜값을 사용하게 되는데(20220715)

날짜 형식으로 변환할 때 MySQL 에서는 str_to_date 함수를 사용할 수 있습니다.

%Y 4자리 년도 %T hh:mm:ss
%y 2자리 년도 %r hh:mm:ss AM/PM
%m 2자리 월(01, 02, 10, 11 ...) %M 월 (영문 전체 March, July ...)
%c 월(1, 2, 10, 11 ...) %b 월 (영문 축약 Mar, Jul ...)
%d 2자리 일(01, 01, 10, 11 ...) %W 요일 (영문 전체 Monday, Thursday ...)
%e 일(1, 2, 10, 11 ...) %a 요일 (영문 축약 Mon, Thu ...) 
%H 24시간제 시간    
%l 12시간제 시간    
%i 2자리 분 (05, 15 ...)    
%S 2자리 초 (05, 15 ...)    

사용 방법은 위 포맷을 참고하여 아래와 같이 사용해 주시면 됩니다.

하지만 아래와 같이 31을 넘어가는 날짜가 입력되면 null을 출력하지만 

4월31을 입력할 경우 4월30일 에서 하루 지난 5월1일을 출력하는 오류가 있습니다.

-- MySQL 5.7.37 / MySQL 8.0.23 / MariaDB 10.1.48 모두에서 아래와 같이 출력 됩니다.

select str_to_date(20220230, '%Y%m%d');   -- 2022-03-02 출력 (Error: 22년 2월은 28일 까지만 존재)
select str_to_date(20220430, '%Y%m%d');   -- 2022-04-30 출력
select str_to_date(20220431, '%Y%m%d');   -- 2022-05-01 출력 (Error: 4월은 30일 까지만 존재함)
select str_to_date(20220432, '%Y%m%d');   -- null 출력
select str_to_date(20220531, '%Y%m%d');   -- 2022-05-31 출력
select str_to_date(20220532, '%Y%m%d');   -- null 출력

입력된 날짜의 무결성이 중요하다면 함수를 만들어 사용하는 것이 좋을 것 같습니다.

반응형
반응형

쿼리창에서 괄호를 열때 자동으로 닫음이 추가되어 불편하신 분들은 아래 옵션을 해제하시면 됩니다.

Editor > General > Smart Keys 메뉴에 들어가셔서.

반응형
반응형

✳️ 첨부 파일은 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

+ Recent posts