기본 콘텐츠로 건너뛰기

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로 가야할듯.

댓글

이 블로그의 인기 게시물

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/" 이렇게 사용하면

MQTT Broker Mosquitto 설치 후 설정

우분투 기준 $ sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa $ sudo apt-get update 하고 $ sudo apt-get install mosquitto 으로 설치하면 서비스까지 착실하게 올라간다. 설치는 간단한데 사용자를 만들어야한다. /etc/mosquitto/mosquitto.conf 파일에서 권한 설정을 변경하자. allow_anonymous false 를 추가해서 아무나 못들어오게 하자. $ service mosquitto restart 서비스를 재시작. 이제 사용자를 추가하자. mosquitto_passwd <암호파일 경로명> <사용자명> 하면 쉽게 만들 수 있다. # mosquitto_passwd /etc/mosquitto/passwd admin Password:  Reenter password:  암호 넣어준다. 두번 넣어준다. 이제 MQTT 약을 열심히 팔아서 Broker 사글세방 임대업을 하자.

OS X 터미널에서 tmux 사용시 pane 크기 조절

http://superuser.com/a/660072  글 참조. OS X 에서 tmux 사용시 나눠놓은 pane 크기 조정할 때 원래는 ctrl+b, ctrl+↑←→↓ 로 사이즈를 조정하는데 기본 터미널 키 입력이 조금 문제가 있다. 키 매핑을 다시 하자 Preferences(cmd+,) > Profile >  변경하고자 하는 Theme 선택 > Keyboards 로 들어가서 \033[1;5A \033[1;5B \033[1;5C \033[1;5D 를 순서대로 ↑↓→←순으로 매핑이 되도록 하면 된다. +를 누르고 Key에 해당 화살표키와 Modifier에 ctrl 선택 한 후 <esc>, [, 1, ;, 5 까지 한키 한키 입력 후 A,B,C,D를 써준다. 잘못 입력했을 땐 당황하지 말고 Delete on character 버튼을 눌러 수정하도록 하자. 그리고 다시 tmux에서 ctrl+b, ctrl+↑←→↓로 사이즈를 조절해보자. 잘 된다.