Skip to content

Commit

Permalink
Deposits and addresses procesing
Browse files Browse the repository at this point in the history
  • Loading branch information
demuskov committed Mar 12, 2018
1 parent e443868 commit 3c1f437
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 6 deletions.
18 changes: 18 additions & 0 deletions db/migrate/20180412000356_create_currencies_summary.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class CreateCurrenciesSummary < ActiveRecord::Migration
def change
create_table :currencies_summary do |t|
t.string :currency
t.decimal :locked, :precision => 32, :scale => 16
t.decimal :balance, :precision => 32, :scale => 16
t.decimal :hot, :precision => 32, :scale => 16
t.timestamps
end
create_table :turnover_summary do |t|
t.decimal :btc, :precision => 32, :scale => 16
t.decimal :ltc, :precision => 32, :scale => 16
t.decimal :doge, :precision => 32, :scale => 16
t.decimal :eth, :precision => 32, :scale => 16
t.timestamps
end
end
end
5 changes: 4 additions & 1 deletion lib/daemons/amqp_daemon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

terminate = proc do
# logger is forbidden in signal handling, just use puts here
puts "Terminating threads .."
puts "Terminating threads ..."
ch.work_pool.kill
puts "Stopped."
end
Expand Down Expand Up @@ -79,3 +79,6 @@
end

ch.work_pool.join

#puts "Stopping channel..."
#ch.close
22 changes: 22 additions & 0 deletions lib/daemons/deposit_coin_address_ctl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons/rails/config'

num = ENV['DEPOSIT_COIN_ADDRESS'] ? ENV['DEPOSIT_COIN_ADDRESS'].to_i : 1

num.times do |i|
if pid = fork
Process.detach pid
else
config = Daemons::Rails::Config.for_controller(File.expand_path(__FILE__))

config[:app_name] = "peatio:amqp:deposit_coin_address:#{i+1}"
config[:script] = "#{File.expand_path('../amqp_daemon.rb', __FILE__)}"
config[:ARGV] = ARGV + %w(-- deposit_coin_address)

Daemons::Rails.run config[:script], config.to_hash

break
end
end

21 changes: 16 additions & 5 deletions lib/daemons/deposit_coin_ctl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@
require 'rubygems'
require 'daemons/rails/config'

config = Daemons::Rails::Config.for_controller(File.expand_path(__FILE__))
num = ENV['DEPOSIT_COIN'] ? ENV['DEPOSIT_COIN'].to_i : 1

config[:app_name] = 'peatio:amqp:deposit_coin'
config[:script] = "#{File.expand_path('../amqp_daemon.rb', __FILE__)}"
config[:ARGV] = ARGV + %w(-- deposit_coin deposit_coin_address)
num.times do |i|
if pid = fork
Process.detach pid
else
config = Daemons::Rails::Config.for_controller(File.expand_path(__FILE__))

config[:app_name] = "peatio:amqp:deposit_coin:#{i+1}"
config[:script] = "#{File.expand_path('../amqp_daemon.rb', __FILE__)}"
config[:ARGV] = ARGV + %w(-- deposit_coin)

Daemons::Rails.run config[:script], config.to_hash

break
end
end

Daemons::Rails.run config[:script], config.to_hash
6 changes: 6 additions & 0 deletions restart_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
bundle exec rake assets:precompile
exec ./restart_daemons.sh
sudo service nginx restart



39 changes: 39 additions & 0 deletions restart_daemons.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# stop
bundle exec rake daemon:matching:stop
bundle exec rake daemon:withdraw_coin:stop
bundle exec rake daemon:notification:stop
bundle exec rake daemon:withdraw_audit:stop
bundle exec rake daemon:market_data:stop
bundle exec rake daemon:hot_wallets:stop
bundle exec rake daemon:payment_transaction:stop
bundle exec rake daemon:k:stop
bundle exec rake daemon:websocket_api:stop
bundle exec rake daemon:stats:stop
bundle exec rake daemon:pusher:stop
bundle exec rake daemon:global_state:stop

bundle exec rake DEPOSIT_COIN=5 daemon:deposit_coin:stop
bundle exec rake TRADE_EXECUTOR=5 daemon:trade_executor:stop
bundle exec rake DEPOSIT_COIN_ADDRESS=4 daemon:deposit_coin_address:stop
bundle exec rake ORDER_PROCESSOR=5 daemon:order_processor:stop

# start
bundle exec rake daemon:matching:start
bundle exec rake daemon:withdraw_coin:start
bundle exec rake daemon:notification:start
bundle exec rake daemon:withdraw_audit:start
bundle exec rake daemon:market_data:start
bundle exec rake daemon:hot_wallets:start
bundle exec rake daemon:payment_transaction:start
bundle exec rake daemon:k:start
bundle exec rake daemon:websocket_api:start
bundle exec rake daemon:stats:start
bundle exec rake daemon:pusher:start
bundle exec rake daemon:global_state:start

bundle exec rake DEPOSIT_COIN=5 daemon:deposit_coin:start
bundle exec rake TRADE_EXECUTOR=5 daemon:trade_executor:start
bundle exec rake DEPOSIT_COIN_ADDRESS=4 daemon:deposit_coin_address:start
bundle exec rake ORDER_PROCESSOR=5 daemon:order_processor:start


0 comments on commit 3c1f437

Please sign in to comment.