기본 콘텐츠로 건너뛰기

Peatio 분투기

흠 요즘은 ruby 할때 puma(https://github.com/puma/puma)를? 패신저는 안쓰남.
https://github.com/peatio/peatio/blob/master/doc/setup-local-osx.md
로컬 환경 먼저 잡자.
brew, rbenv 설치하고 ruby를 2.2.1로 설정하자.
gem install bundler을 설치
Fetching: bundler-1.15.4.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

sudo chown -R $USER /Library/Ruby/Gems/ 하고 나면
gem install bundler
Fetching: bundler-1.15.4.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.

또 오류. 에잇 귀찮아 sudo install bundler 해버림.

mysql 설치
brew install mysql 설치하고
mysql.server start 기동.

redis 설치
brew install redis
redis-server /usr/local/etc/redis.conf

rabbitMQ 설치 얘는 /usr/local/sbin 여기에 설치되니
brew install rabbitmq
rabbitmq-server


bitcore 도 다운 받고 https://bitcoin.org/en/download

mkdir -p ~/Library/Application\ Support/Bitcoin
touch ~/Library/Application\ Support/Bitcoin/bitcoin.conf
vim ~/Library/Application\ Support/Bitcoin/bitcoin.conf
다행히도 testnet 은 153GB씩 안하는 듯.
server=1
daemon=1

# If run on the test network instead of the real bitcoin network
testnet=1

# You must set rpcuser and rpcpassword to secure the JSON-RPC api
# Please make rpcpassword to something secure, `5gKAgrJv8CQr2CGUhjVbBFLSj29HnE6YGXvfykHJzS3k` for example.
# Listen for JSON-RPC connections on (default: 8332 or testnet: 18332)
rpcuser=INVENT_A_UNIQUE_USERNAME
rpcpassword=INVENT_A_UNIQUE_PASSWORD
rpcport=18332

# Notify when receiving coins
walletnotify=/usr/local/sbin/rabbitmqadmin publish routing_key=peatio.deposit.coin payload='{"txid":"%s", "channel_key":"satoshi"}'

하고나서 데몬 띄우고 open /Applications/Bitcoin-Qt.app

테스트넷이라 방심했더니 disk full.
일단 내려놓고 용량 확보 후
brew install phantomjs
brew install imagemagick

하면서 Peatio clone 함
git clone git://github.com/peatio/peatio.git
cd peatio
bundle install
bundle install 이 진짜 오래걸림.
그리고 root 암호도 종종 물어봄. 싹 귀찮네.
자다깨다를 반복.
Fetching ffi 1.9.3......... 오래걸린다...

그러다가 갑자기.
Retrying download gem from https://rubygems.org/ due to error (2/4): Gem::RemoteFetcher::FetchError too many connection resets (https://rubygems.org/gems/ffi-1.9.3.gem)
엥 뭐지?
아몰랑 첨부터 다시 하니

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/Library/Ruby/Gems/2.0.0/extensions/universal-darwin-16/2.0.0/eventmachine-1.0.4/mkmf.log

current directory:
/private/var/folders/9_/4p3ry0ks44g0jn2zl25cr8bw0000gn/T/bundler20171009-5586-48ljfbeventmachine-1.0.4/gems/eventmachine-1.0.4/ext
make "DESTDIR=" clean

current directory:
/private/var/folders/9_/4p3ry0ks44g0jn2zl25cr8bw0000gn/T/bundler20171009-5586-48ljfbeventmachine-1.0.4/gems/eventmachine-1.0.4/ext
make "DESTDIR="
compiling binder.cpp
In file included from binder.cpp:20:
./project.h:112:10: fatal error: 'openssl/ssl.h' file not found
#include
^~~~~~~~~~~~~~~
1 error generated.
make: *** [binder.o] Error 1

make failed, exit code 2

Gem files will remain installed in
/var/folders/9_/4p3ry0ks44g0jn2zl25cr8bw0000gn/T/bundler20171009-5586-48ljfbeventmachine-1.0.4/gems/eventmachine-1.0.4
for inspection.
Results logged to
/Library/Ruby/Gems/2.0.0/extensions/universal-darwin-16/2.0.0/eventmachine-1.0.4/gem_make.out

An error occurred while installing eventmachine (1.0.4), and Bundler cannot continue.
Make sure that `gem install eventmachine -v '1.0.4'` succeeds before bundling.

In Gemfile:
amqp was resolved to 1.3.0, which depends on
eventmachine

아으 eventmachine이 오류. openssl 설치했던 것 같은데 아닌가?
export LD_LIBRARY_PATH=$(brew --prefix openssl)/lib
export CPATH=$(brew --prefix openssl)/include
export PKG_CONFIG_PATH=$(brew --prefix openssl)/lib/pkgconfig
하고 다시 하니 잘된다. (https://github.com/libimobiledevice/libimobiledevice/issues/389#issuecomment-289284190) 참조함.

Depending on your version of ruby, you may need to install ruby rdoc/ri data:

<= 1.8.6 : unsupported = 1.8.7 : gem install rdoc-data; rdoc-data --install = 1.9.1 : gem install rdoc-data; rdoc-data --install >= 1.9.2 : nothing to do! Yay!

다 되었다. 진짜 오래 걸렸네.
그럼 db setup을 해볼까
$ bundle exec rake db:setup
Could not find aasm-3.4.0 in any of the sources
Run `bundle install` to install missing gems.

bundle version 탓인가
$ gem install bundler --pre
ERROR: While executing gem ... (Gem::FilePermissionError)
권한에서부터 뭔가 문제 있는거 아닌가.

$ sudo gem install bundler --pre
Password:
Successfully installed bundler-1.16.0.pre.3
되긴 되었다.

bundle exec rake db:setup 하니
$ bundle exec rake db:setup
rake aborted!
Bundler::GemRequireError: There was an error while trying to load the gem 'mysql2'.
Gem Load Error is: uninitialized constant Mysql2::Client::SECURE_CONNECTION
Backtrace for gem load error is:

음. 또 버전 문제인가.
https://github.com/brianmario/mysql2/issues/754#issuecomment-291564933
이거 보고 재시도. DB 버전을 바꿨다.

rake aborted!
ActiveRecord::StatementInvalid: Mysql2::Error: All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead: CREATE TABLE `account_versions` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `member_id` int(11), `account_id` int(11), `reason` int(11), `balance` decimal(32,16), `locked` decimal(32,16), `fee` decimal(32,16), `amount` decimal(32,16), `modifiable_id` int(11), `modifiable_type` varchar(255), `created_at` datetime, `updated_at` datetime, `currency` int(11), `fun` int(11)) ENGINE=InnoDB

뭐냐 왜 Primary key가 null이라고;
https://github.com/peatio/peatio/issues/590
이 문제로구만.
https://stackoverflow.com/a/40758542 이걸보고
config/initializers/abstract_mysql2_adapter.rb 에 아래를 추가함.

require 'active_record/connection_adapters/mysql2_adapter'

class ActiveRecord::ConnectionAdapters::Mysql2Adapter
NATIVE_DATABASE_TYPES[:primary_key] = "int(11) auto_increment PRIMARY KEY"
end

우여곡절끝에 뜨긴 떴구만.

눈물의 화면

개발환경은 이정도인데 OS X에서 하는 거 고통스럽다.
그냥 바로 linux로 가야할듯.

댓글

이 블로그의 인기 게시물

MQTT 접속해제 - LWT(Last will and testament)

통신에서 중요하지만 구현이 까다로운 문제로 "상대방이 예상치 못한 상황으로 인하여 접속이 끊어졌을때"의 처리가 있다. 이것이 까다로운 이유는 상대방이 의도적으로 접속을 종료한 경우는 접속 종료 직전에 자신의 종료 여부를 알리고 나갈 수 있지만 프로그램 오류/네트웍 연결 강제 종료와 같은 의도치 않은 상황에선 자신의 종료를 알릴 수 있는 방법 자체가 없기 때문이다. 그래서 전통적 방식으로는 자신의 생존 여부를 계속 ping을 통해 서버가 물어보고 timeout 시간안에 pong이 안올 경우 서버에서 접속 종료를 인식하는 번거로운 방식을 취하는데 MQTT의 경우 subscribe 시점에서 자신이 접속 종료가 되었을 때 특정 topic으로 지정한 메시지를 보내도록 미리 설정할 수 있다. 이를 LWT(Last will and testament) 라고 한다. 선언을 먼저하고 브로커가 처리하게 하는 방식인 것이다. Last Will And Testament 라는 말 자체도 흥미롭다. 법률용어인데  http://www.investopedia.com/terms/l/last-will-and-testament.asp 대략 내가 죽으면 뒷산 xx평은 작은 아들에게 물려주고 어쩌고 하는 상속 문서 같은 내용이다. 즉, 내가 죽었을(연결이 끊어졌을) 때에 변호사(MQTT Broker - ex. mosquitto/mosca/rabbitMQ등)로 하여금 나의 유언(메시지)를 상속자(해당 토픽에 가입한 subscriber)에게 전달한다라는 의미가 된다. MQTT Client 가 있다면 한번 실습해보자. 여러가지가 있겠지만 다른 글에서처럼  https://www.npmjs.com/package/mqtt  을 사용하도록 한다. npm install mqtt --save 로 설치해도 되고 내 경우는 자주 사용하는 편이어서 npm install -g mqtt 로 전역설치를 했다. 호스트는 무료 제공하고 있는 test.mosquitto.o...

Renoise로 바닥부터 Sound Design (No Sample/No VST)

Renoise는 Ableton Live Standard 버전처럼 기본적으로 아무 악기가 없고 달랑 샘플러 하나가 전부인데 그마나 다행인건 멀티레이어라고나 할까. 샘플러만 있으면 사실 다 되지. 아날로그 웨이브 테이블을 최소단위로 넣어서 루프를 돌리면  되니까. 근데 그러면 무조건 폴리포니가 되어서 구조적으로 모노 신스는 구현이 불가능하다. 그것도 방법이 없는 건 아닌데 Bend 라든가 Glide 등등으로 하면 되니까. 그래도 모노 신스가 있었으면 좋겠는데 방법이 있더라. http://forum.renoise.com/index.php?/topic/27225-renoise-native-monophonic-synthesiser/  이 글을 보고 약간 충격을 받음. 이펙터만 있으면 역시 소리를 만들 수 있구나! 바로 시도에 들어감. 처음은 이런 상태. 나는 누군가. 여긴 어딘가. 키보드를 눌러도 아무 소리가 안난다. ESC 눌러서 첫번째 트랙 맨위에 Z(C-4 00) 하나 눌러 놓고 일단 플레이. 일단 이렇게 해놓고 소리가 날 수 있게 한단 말이지. 그럼 먼저 제네레이터. 일단 1byte짜리라도 뭐가 있어야 시작을 할 수 있으니 빈 샘플을 만들자. 1byte 짜리 빈 샘플을 만든다. 당연히 소리가 안난다. DC Offset을 만들어 00 인 상태를 바꿔보자. 퍽하고 클릭음이 생기면서 Master Scope 에 변화가 생겼다. Meter도 생겼다. 그런데 이건 소리라고 할 수 없다. RingMod(Ring Modulator)를 추가해보자. 오오 소리가 난다. 0인 경우엔 Ring Modulator를 적용해도 0으로 소용이 없지만 DC Offset으로 값을 변경한 후부터 Oscillator에 따라 파형이 생긴다. 기본적으로 440Hz의 음을 들을 수 있다. 무에서 유를 만들기는 했는데 Pitch도 Volume도 없다. 일단 Pitch부터 해보자. Key Tracker로 Dest...

cURL로 cookie를 다루는 법

http://stackoverflow.com/questions/22252226/passport-local-strategy-and-curl 레거시 소스를 보다보면 인증 관련해서 cookie를 사용하는 경우가 있는데 가령 REST 서버인 경우 curl -H "Content-Type: application/json" -X POST -d '{"email": "aaa@bbb.com", "pw": "cccc"}' "http://localhost/login" 이렇게 로그인이 성공이 했더라도 curl -H "Content-Type: application/json" -X GET -d '' "http://localhost/accounts/" 이런 식으로 했을 때 쿠키를 사용한다면 당연히 인증 오류가 날 것이다. curl의 --cookie-jar 와 --cookie 옵션을 사용해서 cookie를 저장하고 꺼내쓰자. 각각 옵션 뒤엔 저장하고 꺼내쓸 파일이름을 임의로 지정하면 된다. 위의 과정을 다시 수정해서 적용하면 curl -H --cookie-jar jarfile "Content-Type: application/json" -X POST -d '{"email": "aaa@bbb.com", "pw": "cccc"}' "http://localhost/login" curl -H --cookie jarfile "Content-Type: application/json" -X GET -d '' "http://localhost/accounts/" 이렇게 사용하면 ...