레드마인에 Hipchat을! Rocket.chat 설치

1.
Atlassian의 Jira와 Hipchat를 공급하는 프로젝트를 수행한 적이 있습니다. 이 때 Hipchat을 설치하면서 겪었던 경험을 인터넷과 GUI 없이 VIRTUALBOX 사용하기에서 정리하였습니다. 이메일과 다른 실시간 메시징방식으로 알람을 처리하는 것에 관심이 많았지만 직접 사용할 수 없었습니다. 이후 Jira를 대신하여 레드마인을 프로젝트 도구로 바꾸고 우여곡절끝에 라즈베리파이에 설치하여 사용하고 있습니다.

USB부팅하는 라즈베리파이 서버 만들기

이음이 진행하는 내외 프로젝트를 레드마인으로 협업하면서 실시간 메시징과의 통합을 여러번 시도하였습니다. 그중 하나가 Slack이었지만 유료가 걸려서 포기하였습니다. 무료로 제공하는 서비스중 마이크로소프트의 Teams를 무료로 사용할 수 있지만 레드마인과의 통합이 쉽지 않아서 포기하였습니다. 리눅스와 관련한 글을 보면서 시도하려고 했던 서비스가 Rocket.chat입니다. 오픈소스이고 레드마인과 같은 다양한 시스템과의 통합환경도 제공하기때문입니다.

역시사 설치환경은 Raspberry Pi B+이고 Ubuntu Mate 16.04입니다. 우선 Rocket.Chat을 Raspberry Pi에 설치하는 방법을 잘 정리한 문서는  Rocket.Chat.RaspberryPi입니다. 글을 읽어보면 명령어 두번이면 설치가 끝입니다. 먼저 snapd를 설치하고 snap을 이용하여 rocket.chat을 설치합니다.

sudo apt update && sudo apt install snapd
sudo snap install rocketchat-server

너무 간단하여 주저없이 바로 시도하였습니다. 그리고 실행하였습니다만 행복은 잠시였습니다. 아래와 같은 오류를 확인하였습니다.

snap.rocketchat-server.rocketchat-server.service – Service for snap application rocketchat-server.rocketchat-server
Loaded: loaded (/etc/systemd/system/snap.rocketchat-server.rocketchat-server.service; enabled; vendor preset: enabled)
Active: failed (Result: start-limit-hit) since 목 2018-12-13 10:35:06 KST; 25min ago
Process: 15414 ExecStart=/usr/bin/snap run rocketchat-server (code=exited, status=1/FAILURE)
Main PID: 15414 (code=exited, status=1/FAILURE)

And Log is below.
12월 13 08:52:32 ium-desktop systemd[1]: Started Service for snap application rocketchat-server.rocketchat-server.
12월 13 08:52:35 ium-desktop rocketchat-server.rocketchat-server[770]: cannot apply seccomp profile: Invalid argument

저도 생소한 seccomp가 등장합니다. 위키를 보면 snap이 seccomp를 사용합니다.

Snap specify the shape of their application sandbox using ‘interfaces’ which snapd translates to seccomp, AppArmor and other security constructs

open.rocket.chat으로 문의를 하니까 Ubuntu Mate는 linux-raspi2 kernel package 를 사용하지 않으므로 Raspbian Stretch로 OS를 바꾸라고 합네요.

The raspberry pi foundation kernel (same as in raspbian) is used by ubuntu-mate. There is though a ubuntu rpi kernel package – https://launchpad.net/ubuntu/+source/linux-raspi2 – it’s just not used by Mate

그래서 무작정 Rocket.Chat in UbuntuHow to Install Rocket.Chat Server with Nginx on Ubuntu 16.04을 참고로 해서 직접 설치를 하였습니다. 설치를 시작하면서 제일 먼저 난관은 mongoDB입니다. Ubuntu 16.04는 64비트의 MongoDB만을 지원합니다. 32bit를 지원하지 않기때문에 정상적인 방법으로 설치할 수 없습니다. 그래서 32bit를 설치할 수 있는 방법을 찾아보니까 두개의 글이 잘 정리해놓았습니다.

MongoDB 3.0.9 binaries for Raspberry Pi 2 & 3 (Jessie)을 참조하여 Salman Zari Ghanvi가 An alternate to slack on Pi 3 (Rocket.Chat)에서 자세히 설명해주고 있습니다. 더불어 설치할 수 있는 Shell까지 제공합니다. 아래를 실행하면 MongoDB와 관련한 고민은 끝입니다.

2.
이제 Rocket.chat을 설치할 차례입니다. Rocker.Chat는 node.js를 기반으로 만들어진 오픈소스 프로젝트입니다. Node.js를 단어로만 알고 있는 처지라 관련한 설치작업을 하면서 많이 헷갈렸습니다. n – Interactively Manage Your Node.js Versions을 이용하여 원하는 버전을 설치하실 수 있고 Install Node.js and Npm on Raspberry Pi처럼 wget으로 파일을 받아서 직접 설치하실 수도 있습니다. 저같은 경우 처음 apt-get install nodejs와 같은 식으로 설치를 하였더니 최신 버전인 10.14.2를 설치하더군요. 모든 설치작업을 마치고 rocket.chat을 실행하였더니 nodejs 버전이 맞지 않는다고 다운그레이드를 하라는 메시지를 만났습니다. 똑같은 작업을 다시금 반복했어야 했습니다. 저같은 실수를 하지 않으려면 앞서 ubuntu 설치순서에 따라 아무 생각없이 명령어를 입력하지말고 Rocket.chat Server를 지원하는 버전이 설치되도록 하여야 합니다.

이제 rocket.chat 서버를 받아서 설치를 하는 순서입니다. 앞서 설치설명을 보면 다음과 같이 하라고 합니다.

curl -L https://releases.rocket.chat/latest/download -o /tmp/rocket.chat.tgz
tar -xzf /tmp/rocket.chat.tgz -C /tmp
cd /tmp/bundle/programs/server && npm install

마지막 npm install을 실행하면 phantomJS를 제외하고 정상적으로 설치하였다고 나옵니다. 우선 Rocket.Chat이 사용하는 phantomJS 버전은 1.9.20입니다. 이 버전을 설치하시 못하고 npm install에 ‘phantomjs@2.1,1’이라는 옵션을 붙여서 설치를 하였습니다. 그리고 rocket.chat을 실행하였더니 오류가 발생하군요.

rocketchat.service – The Rocket.Chat server
Loaded: loaded (/lib/systemd/system/rocketchat.service; enabled; vendor preset: enabled)
Active: active (running) since 목 2018-12-13 18:03:08 KST; 1min 21s ago
Main PID: 12152 (node)
CGroup: /system.slice/rocketchat.service
└─12152 /usr/local/bin/node /opt/Rocket.Chat/main.js

12월 13 18:03:51 ium-desktop rocketchat[12152]: at Module.require (packages/modules-runtime.js:238:14)
12월 13 18:03:51 ium-desktop rocketchat[12152]: at require (packages/modules-runtime.js:258:21)
12월 13 18:03:51 ium-desktop rocketchat[12152]: at /opt/Rocket.Chat/programs/server/packages/rocketchat_assets.js:643:15
12월 13 18:03:51 ium-desktop rocketchat[12152]: at /opt/Rocket.Chat/programs/server/packages/rocketchat_assets.js:648:3
12월 13 18:03:51 ium-desktop rocketchat[12152]: at /opt/Rocket.Chat/programs/server/boot.js:411:36
12월 13 18:03:51 ium-desktop rocketchat[12152]: at Array.forEach ()
12월 13 18:03:51 ium-desktop rocketchat[12152]: at /opt/Rocket.Chat/programs/server/boot.js:220:19
12월 13 18:03:51 ium-desktop rocketchat[12152]: at /opt/Rocket.Chat/programs/server/boot.js:471:5
12월 13 18:03:51 ium-desktop rocketchat[12152]: at Function.run (/opt/Rocket.Chat/programs/server/profile.js:510:12)
12월 13 18:03:51 ium-desktop rocketchat[12152]: at /opt/Rocket.Chat/programs/server/boot.js:470:11

원인을 알 수 없었습니다. 여기저기 검색을 해보니까 -‘-verbose’를 더하면 터미널에서 바로 로그를 볼 수 있더군요. 이렇게 해서 실행을 해보니까..

node ./main.js –verbose
Updating process.env.MAIL_URL
Starting Email Intercepter…
Note: you are using a pure-JavaScript implementation of bcrypt.
While this implementation will work correctly, it is known to be
approximately three times slower than the native implementation.
In order to use the native implementation instead, run

meteor npm install –save bcrypt

in the root directory of your application.
Exception in callback of async function: Error: /tmp/bundle/programs/server/npm/node_modules/sharp/build/Release/sharp.node: wrong ELF class: ELFCLASS64
at Object.Module._extensions..node (internal/modules/cjs/loader.js:718:18)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)

node와 관련한 라이브러리가 raspberryPi와 맞지 않았습니다. Sharp 프로그램을 재설치하여야 하는데 그냥 설치하면 오류가 나서 검색을 해보니까 소스를 받아서 컴파일한 후 설치하는 옵션이 있더군요. 역시나 디버깅을 위하여 –verbose를 덧붙였습니다.

npm install sharp -g –build-from-source –verbose

npm install과 node ./main.js를 반복해서 실행해보니까 node와 관련한 라이브러리중 재컴파일이 필요한 것이 있었습니다. sharp, grpc, fibers, phantomJS입니다. 이상을 설치하고 rocket.chat을 실행하니까 아래와 같은 메시지를 확인할 수 있었습니다. 역시나 –verbose로 확인하였습니다.

Using GridFS for custom sounds storage
Using GridFS for custom emoji storage
Loaded the Apps Framework and loaded a total of 0 Apps!
System ➔ startup
+————————————————–+
| SERVER RUNNING |
+————————————————–+
| |
| Rocket.Chat Version: 0.72.3 |
| NodeJS Version: 8.14.0 – arm |
| Platform: linux |
| Process Port: 3000 |
| Site URL: http://********:3000/ |
| ReplicaSet OpLog: Disabled |
| Commit Hash: 65747ce814 |
| Commit Branch: HEAD |
| |
+————————————————–+
Thansk..

3.
이제 모바일접속을 위하여 ssl을 지원하도록 Reverse Proxy를 설정합니다. 예전과 다르게 SSL서비스를 인증서를 설치하는 일이 무척이나 쉽네요. 무료로 인증서비스를 제공하는 곳이 있습니다. 설치하면서 보니까 EFF와 관계가 있더군요.

Let’s Encrypt – Free SSL/TLS Certificates

Let’sencrypt가 제시하는 방법은 아래와 같이 직접 cerbot를 설치하는 것입니다.

저는 Redmine 서비스를 위하여 Nginx를 사용하고 있지만 apt 명령어로 설치하지 않고 다운로드받아서 직접 설치하였습니다. 그래서 위와 같은 방식으로 설치를 하면 nginx를 이중으로 설치하는 문제가 발생합니다. 다른 방법을 찾으니까 아래와 같이 강제로 설치하는 방법을 제시하는 곳도 있었습니다.

You can do that downloading the needed packages and after that permorfing a manual install, forcing them. Do it at your own risk, I don’t recommend this method at all:

mkdir /tmp/python-certbot-nginx
chmod 777 /tmp/python-certbot-nginx/
cd /tmp/python-certbot-nginx/
sudo apt-get download python-certbot-nginx python-pyparsing
sudo dpkg –force-all -i *.deb
As I said, I never would use this method because it can damage/broke some other packages, as an alternative, you could use certbot-auto instead of the certbot package provided by Ubuntu. certbot-auto includes the nginx plugin and it won’t try to install nginx package.

Here the instructions to install certbot-auto: https://certbot.eff.org/#pip-nginx 19

Also, if you install certbot-auto, maybe you would like to remove the certbot package installed in your system. Before performing any delete action, remember to backup you /etc/letsencrypt/ dir

As root:

cd
tar zcvf backup_etc-letsencrypt_2017-Oct-22.tar.gz /etc/letsencrypt/
Good luck,
sahsanu
Install python-certbot-nginx without reinstalling Nginx중에서

좀더 자세히 읽어보니까 nginx를 재설치하지 않고, 또 중복설치할 필요없이 이미 설치된 nginx를 이용할 수 있는 방법이 있더군요. Automatically enable HTTPS on your website with EFF’s Certbot, deploying Let’s Encrypt certificates.가 제시한 cert-auto를 이용하여 설치를 하였습니다. et’s Encrypt SSL 무료 인증서 certbot을 통해 설치 및 설정하는 방법을 참고로 하여도 됩니다. 설치한 후 명령어를 실행하니까 다음과 알림이 나오면서 설정을 합니다.

Certbot doesn’t know how to automatically configure the web server on this system. However, it can still get a certificate for you. Please run “certbot-auto certonly” to do so. You’ll need to manually configure your web server to use the resulting certificate.

이렇게 해서 생성한 파일은 다음과 같습니다.

이제 nginx를 reverse proxy로 설정하기 위하여 configuration 파일을 수정합니다. How to Install Rocket.Chat Server with Nginx on Ubuntu 16.04에서 자세한 정보를 얻을 수 있습니다. 저는 nginx를 사용하기 때문에 아래를 추가하였습니다.

# Upstreams
upstream backend {
server 127.0.0.1:3000;
}

# Redirect Options
server {
listen 80;
server_name rocket-chat.co;
# enforce https
return 301 https://$server_name$request_uri;
}

# HTTPS Server
server {
listen 443;
server_name rocket-chat.co;

error_log /var/log/nginx/rocketchat.access.log;

ssl on;
ssl_certificate /etc/nginx/ssl/rocket-chat.crt;
ssl_certificate_key /etc/nginx/ssl/rocket-chat.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # dont use SSLv3 ref: POODLE

location / {
proxy_pass http://192.168.1.110:3000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
proxy_set_header Host $http_host;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forward-Proto http;
proxy_set_header X-Nginx-Proxy true;

proxy_redirect off;
}
}

다만 이미 iumgroup.biz를 Redmine 서비스로 사용하고 있기때문에 Redirect Options의 설정값을 약간 변경하여 처리하였습니다. 이상을 처리한 후 모바일 화면에서 접속하면 아래와 비슷한 화면을 만납니다. 앞서 프로젝트를 할 때 Hipchat과 비교하면 괜찮은 서비스입니다. Raspberry Pi에 설치를 해서 복잡하지 만약 X.86계열의 CPU라고 하면 snapd로 손쉽게 설치 이용할 수 있을 듯 합니다.

마지막으로 레드마인과 Rocketchat을 연결하려면 레드마인에 redmine_messenger을 설치하면 됩니다. 저도 정상적으로 동작함을 확인하였습니다.

Leave a Comment

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.