diff --git a/db/migrate/20180412000356_create_currencies_summary.rb b/db/migrate/20180412000356_create_currencies_summary.rb new file mode 100644 index 0000000000..ab152f6e61 --- /dev/null +++ b/db/migrate/20180412000356_create_currencies_summary.rb @@ -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 diff --git a/lib/daemons/amqp_daemon.rb b/lib/daemons/amqp_daemon.rb index 821bb039e9..db838ccca6 100644 --- a/lib/daemons/amqp_daemon.rb +++ b/lib/daemons/amqp_daemon.rb @@ -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 @@ -79,3 +79,6 @@ end ch.work_pool.join + +#puts "Stopping channel..." +#ch.close diff --git a/lib/daemons/deposit_coin_address_ctl b/lib/daemons/deposit_coin_address_ctl new file mode 100755 index 0000000000..a82283f5e7 --- /dev/null +++ b/lib/daemons/deposit_coin_address_ctl @@ -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 + diff --git a/lib/daemons/deposit_coin_ctl b/lib/daemons/deposit_coin_ctl index 71e481f5b1..bfd9d54cdb 100755 --- a/lib/daemons/deposit_coin_ctl +++ b/lib/daemons/deposit_coin_ctl @@ -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 diff --git a/restart_all.sh b/restart_all.sh new file mode 100755 index 0000000000..d33857be16 --- /dev/null +++ b/restart_all.sh @@ -0,0 +1,6 @@ +bundle exec rake assets:precompile +exec ./restart_daemons.sh +sudo service nginx restart + + + diff --git a/restart_daemons.sh b/restart_daemons.sh new file mode 100755 index 0000000000..e2ba1eea1e --- /dev/null +++ b/restart_daemons.sh @@ -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 + +