# 설치

셀렉트 서버에는 express http api 서버와 빌드된 UI가 내장되어있습니다.

로컬이나 서버에 설정파일을 추가하여 바로 이용 가능합니다.

(2022-01-24 이후부터) 설치형셀렉트에 Redis가 필요합니다.

# npm

  1. 아래의 명령어로 CLI를 설치합니다.

npm install -g selectfromuser

  1. 설치후 같은 폴더에 설정 파일 default.yml을 추가합니다.

설정은 default.yml, [NODE_ENV].yml, local.yml을 불러오도록 되어있습니다.

테스트를 위한 샘플레시피가 준비되어있습니다. default.yml

redis:
  master:
    host: 127.0.0.1
    port: 6379
    db: 0

web: 
  base_url: http://localhost:9400

secret:
  access_token: SECRET

policy:
  session_expire: 48300

google:
  client_id: 
  redirect_uri: 
  client_secret: 
google_sheet:
  client_id: 
  redirect_uri: 
  client_secret: 

select-configuration:
  title: Welcome to Select
  menus:
    - group: 회원
      name: 고객 목록
      path: users/list
    - group: 회원
      name: 휴면회원 목록
      path: users/dormant
      placement: tab-only
    - group: 회원
      name: 마케팅 수신동의
      path: users/promotion
      placement: tab-only
    
    - group: 기타메뉴
      name: 공식 문서 
      path: https://docs.selectfromuser.com
      target: _blank
    - group: 기타메뉴
      name: 클라우드 이용
      path: https://selectfromuser.com
      target: _blank

  access-control:
    
  users:
    - id: admin
      pw: YWRtaW4=
      roles:
        - cs
        - qa
        - admin
        - news
  integrations:
    google-sso:
      enabled: false
      restrict-domain: 
    google-spreadsheets:
      restrict-domain: 
  
  pages:
    - path: users/list
      blocks:
        - type: markdown
          content: >
            # 셀렉트에 오신것을 환영합니다.
        
    - path: users/dormant
      blocks:
        - type: markdown
          content: >
            # 셀렉트에 오신것을 환영합니다.
        
    - path: users/promotion
      blocks:
        - type: markdown
          content: >
            # 셀렉트에 오신것을 환영합니다.
        
  resources:
    # - key: mysql.dev
    #   type: mysql
    #   host: YOUR_HOST.rds.amazonaws.com
    #   port: 3306
    #   username: (디비 계정이름)
    #   password: (base64 인코딩된 디비계정 비밀번호)
    #   database: (데이터베이스이름)
    #   requestTimeout: 3000
    #   timezone: '+00:00'
    #   charset: "utf8mb4_general_ci"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
  1. 셀렉트CLI로 서버를 실행합니다.
$ selectfromuser
1
  1. 아래와 같이 현재 폴더 기준으로 설정(YAML)을 불러와서 어드민 서버를 실행합니다.
$ selectfromuser

  select:admin  start
✓ NODE_CONFIG_DIR = .
✓ DEBUG = (FALSE)
✓ PORT = 8000
✓ LICENSE_KEY = N/A
✓ config[title] = Welcome to Select
✓ config[menus] = 5 item(s)
✓ config[users] = 2 item(s)
✓ config[pages] = 3 item(s)
  select:admin  config[redis] connecting...
  select:admin  config[redis] connected
  select:admin  config[resources] connecting...
  select:admin  server warning: no resources configured.
  select:admin  config[resources] connected
  select:admin  api connected
  select:admin  ready on http://localhost:9400
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  1. 다음과 같이 로그인화면이 보입니다. http://localhost:9400 (opens new window)

위의 설정에 따라 ID/PW: admin/admin 입니다.

# 설정파일 경로 바꾸기

현재 경로(cwd)를 기본값으로 하며불러오는 설정파일의 위치를 바꾸려면 다음과 같이 입력합니다.

NODE_CONFIG_DIR=./config selectfromuser
1

설정파일이 없는 경우 아래의 에러가 표시됩니다.

select:admin ERROR Configuration property "select-configuration" is not defined

select:admin ERROR 설정 파일이 없습니다. default.yml, development.yml local.yaml

# 설정 변경시 자동 재시작하기

YAML 파일 변경시 자동으로 서버를 재시작합니다.

selectfromuser -w
1

아래와 같이 YAML 파일 변경시 재시작 됩니다.

path:  /opt/homebrew/lib/node_modules/selectfromuser
App has started
 INFO  version 1.1.15
 INFO  configuration from /Users/eces/ysg/ysg-admin/default.yml,/Users/eces/ysg/ysg-admin/local.yml
  ✓ NODE_CONFIG_DIR = /opt/homebrew/lib/node_modules/selectfromuser
  ✓ DEBUG = (FALSE)
  ✓ PORT = 8000
  ✓ LICENSE_KEY = Free Plan 무료버전
  ✓ config[title] = 역세권 어드민
  ✓ config[menus] = 4 item(s)
  ✓ config[users] = 2 item(s)
  ✓ config[pages] = 4 item(s)

  select:admin  config[redis] connecting...
  select:admin  config[redis] connected
  select:admin  config[resources] connecting...
  select:admin  config[resources] connected
  select:admin  api connected
  select:admin  ready on http://localhost:8000
App restarted due to:  [ '/Users/eces/ysg/ysg-admin/default.yml' ]
App has started
 INFO  version 1.1.15
 INFO  configuration from /Users/eces/ysg/ysg-admin/default.yml,/Users/eces/ysg/ysg-admin/local.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

# nodemon 별도로 재시작하고 싶은 경우

npm install -g nodemon

config 폴더에 설정이 있는 경우:

NODE_CONFIG_DIR=./config nodemon --exec "selectfromuser" --watch ./config/*.yml

지금 폴더에 설정이 있는 경우:

nodemon --exec "selectfromuser" --watch . -e yml

# DEBUG

인증상태, 쿼리, 블록등 디버그 메시지를 표시합니다.

DEBUG=select* selectfromuser
1

# PM2로 설치

npm i -g selectfromuser
1

app.yml

apps:
  - script: 'selectfromuser'
    name: 'select'
    instances: 1                  # 프로덕션의 경우 2 이상으로 늘이기
    exec_mode: cluster
    max_memory_restart: 500M
    restart_delay: 5000
    kill_timeout: 10000
    listen_timeout: 10000
    wait_ready: true
    env:
      NODE_CONFIG_DIR: ./config   # 설정파일 위치로 지정
    #watch: config/*.yml          # watch reload가 불필요하면 삭제
1
2
3
4
5
6
7
8
9
10
11
12
13
pm2 start app.yml
1

config 폴더에 설정이 있는 경우 이 방법으로 pm2 실행 가능합니다.

# pm2: 여러개 버전의 셀렉트 이용 (global module을 쓰지 않고 배포하기)

여러개 셀렉트 어드민을 운영하는 경우 안정성을 위해 버전을 개별로 고정할수 있습니다.

이 경우 하나씩 순차 업데이트가 가능하며, 기존 어드민은 업데이트에 영향을 받지 않습니다.

해당 폴더에서 npm install selectfromuser 한 다음 직접 바이너리를 호출합니다. (npx selectfromuser)

apps:
  - script: 'node_modules/selectfromuser/bin/select'
    name: 'ysg-admin'
    instances: 1
    exec_mode: fork
    max_memory_restart: 500M
    restart_delay: 1000
    kill_timeout: 3000
    listen_timeout: 3000
    wait_ready: true
    env:
      PORT: 9600
      NODE_ENV: production
1
2
3
4
5
6
7
8
9
10
11
12
13

# Docker로 설치

https://github.com/eces/select/pkgs/container/select (opens new window)

ENV 추가 또는 yml 파일을 mount하여 이용합니다.

docker run -it -v $(pwd)/default.yml:/app/default.yml -p 9400:9400 ghcr.io/eces/select
1

# Docker Compose로 설치

https://github.com/eces/select-onpremise (opens new window)

https://github.com/eces/select-onpremise
1
cd select-onpremise
1
docker-compose up
1

# 디렉토리 구조

  • bin: 셀렉트 CLI
  • dist: 빌드된 UI
  • models
  • routes
  • ui: UI 코드 (npmignore)
  • index.js: entrypoint