cs-service 0.2.2 → 0.3.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -10
- data/config/processes/project.rb +8 -4
- data/config/processes/realtime.rb +10 -13
- data/config/processes/rt_client.rb +11 -0
- data/examples/project.yml +8 -0
- data/lib/cs/service/cli.rb +28 -24
- data/lib/cs/service/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 367e793d07e4406f41af23dcc22b08c60936b719
|
4
|
+
data.tar.gz: 354b5c95c030c2f361a54abdee7bc288d8d1d640
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4a57b80bcd336ba1418b9c9ac78e9526858668c2423cc1f88415a7be811f12ba340a09fcb4d7b00e48d1489f5a0c37683c9f284e95c04386a272bcb2afb0c44
|
7
|
+
data.tar.gz: 5c203d1292de91607a356ec28733c6358ba015015d4f55e508bc42def51bda5a88864482468c03acc6bb4198924e0e83de93dc7c889b38b2aa14fe92898ef529
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# cs-service
|
2
2
|
|
3
3
|
cs-service 财说服务管理工具, 根据项目中的config/project.yml, 来启动相关服务
|
4
4
|
|
@@ -10,14 +10,18 @@ cs-service 财说服务管理工具, 根据项目中的config/project.yml, 来
|
|
10
10
|
|
11
11
|
## Commands:
|
12
12
|
|
13
|
-
cs-service env [ENV_NAME]
|
14
|
-
cs-service eye ...ARGS
|
15
|
-
cs-service help [COMMAND]
|
16
|
-
cs-service info [
|
17
|
-
cs-service load
|
18
|
-
cs-service quit
|
13
|
+
cs-service env [ENV_NAME] # 环境变量检查
|
14
|
+
cs-service eye ...ARGS # 执行eye口令, 详细参考 cs-service eye
|
15
|
+
cs-service help [COMMAND] # 帮助
|
16
|
+
cs-service info [PROJECT] # 查看当前运行状态
|
17
|
+
cs-service load # 首次加载配置文件
|
18
|
+
cs-service quit # 退出 cs-service
|
19
|
+
cs-service restart [PROJECT] # 重启项目
|
20
|
+
cs-service start [PROJECT] # 启动项目
|
21
|
+
cs-service stop [PROJECT] # 停止项目
|
22
|
+
cs-service version # 当前版本
|
19
23
|
|
20
|
-
### Step1
|
24
|
+
### Step1 检查配置是否生效, 是否可以找到有效的配置文件
|
21
25
|
|
22
26
|
$ cs-service env
|
23
27
|
|
@@ -25,14 +29,19 @@ cs-service 财说服务管理工具, 根据项目中的config/project.yml, 来
|
|
25
29
|
|
26
30
|
$ cs-service load
|
27
31
|
|
28
|
-
### Step3
|
32
|
+
### Step3 查看当前加载的项目状态
|
33
|
+
|
34
|
+
$ cs-service info
|
35
|
+
|
36
|
+
### Step4 如果环境设置正确,则启动项目
|
29
37
|
|
30
38
|
$ cs-service start # 启动所有项目
|
39
|
+
|
40
|
+
# 如果单独启动项目
|
31
41
|
$ cs-service start web # 启动caishuo主站
|
32
42
|
$ cs-service start rest_server # 启动Rest Server
|
33
43
|
$ cs-service start trading_server # 启动Trading Server
|
34
44
|
|
35
|
-
|
36
45
|
## Development
|
37
46
|
|
38
47
|
rake build
|
data/config/processes/project.rb
CHANGED
@@ -2,7 +2,7 @@ require 'hashie'
|
|
2
2
|
# 启动项目
|
3
3
|
def run_projects
|
4
4
|
fetch_config_files(project_roots).each do |root_path|
|
5
|
-
project(root_path, ENV['RACK_ENV']||'development')
|
5
|
+
project(root_path, ENV['RACK_ENV'] || 'development')
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
@@ -23,6 +23,12 @@ def project(root_path, env = :development)
|
|
23
23
|
|
24
24
|
process_puma(self, config[:puma]) if config[:puma]
|
25
25
|
process_sneaker(self, config[:sneaker]) if config[:sneaker]
|
26
|
+
|
27
|
+
group :realtime do
|
28
|
+
process_realtime(self, pool: config[:realtime][:pool]) if config[:realtime][:pool]
|
29
|
+
process_rt_client(self) if config[:realtime][:rt_client]
|
30
|
+
end if config[:realtime]
|
31
|
+
|
26
32
|
group :resque do
|
27
33
|
process_scheduler(self) if config[:resque][:scheduler]
|
28
34
|
process_worker(self, config[:resque][:worker]) if config[:resque][:worker]
|
@@ -42,7 +48,5 @@ end
|
|
42
48
|
|
43
49
|
def fetch_config_files(project_roots = [])
|
44
50
|
project_roots << ENV['CURRENT_PWD']
|
45
|
-
|
46
|
-
Eye::Logger.info('========='*100 + ENV['PWD'])
|
47
|
-
a
|
51
|
+
project_roots.compact.uniq.find_all{|project_root| Eye::Logger.info('='*100 + File.join(project_root, 'config', 'project.yml')); File.exist?(File.join(project_root, 'config', 'project.yml'))}
|
48
52
|
end
|
@@ -1,18 +1,15 @@
|
|
1
|
-
def process_realtime(proxy,
|
2
|
-
|
3
|
-
|
4
|
-
(
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
stdall 'log/realtime.log'
|
1
|
+
def process_realtime(proxy, pool: {})
|
2
|
+
pool.each do |market, num|
|
3
|
+
(1..num).each do |i|
|
4
|
+
proxy.process("#{market}_#{i}") do
|
5
|
+
daemonize true
|
6
|
+
pid_file "tmp/pids/realtime_worker_#{market}.#{i}.pid"
|
7
|
+
stdall 'log/realtime.log'
|
9
8
|
|
10
|
-
|
11
|
-
'RACK_ENV' => RACK_ENV
|
9
|
+
env 'PIDFILE' => "tmp/pids/realtime_worker_#{market}.#{i}.pid"
|
12
10
|
|
13
|
-
|
14
|
-
end
|
11
|
+
start_command "bundle exec rake stock:realtime_#{market} --trace"
|
15
12
|
end
|
16
13
|
end
|
17
14
|
end
|
18
|
-
end
|
15
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
def process_rt_client(proxy)
|
2
|
+
proxy.process('rt_client') do
|
3
|
+
daemonize true
|
4
|
+
pid_file 'tmp/pids/rt_client.pid'
|
5
|
+
stdall 'log/realtime.log'
|
6
|
+
|
7
|
+
env 'PIDFILE' => 'tmp/pids/rt_client.pid'
|
8
|
+
|
9
|
+
start_command 'bundle exec rake rt_client:sync --trace'
|
10
|
+
end
|
11
|
+
end
|
data/examples/project.yml
CHANGED
@@ -20,6 +20,14 @@ common: &default_settings
|
|
20
20
|
# 需要启动的sneaker consumer
|
21
21
|
queue: "Trading::PmsConsumer,FeedConsumer,JpushConsumer,StockRealtimeConsumer"
|
22
22
|
|
23
|
+
# 是否开启realtime worker
|
24
|
+
realtime:
|
25
|
+
# 需要启动的realtime worker
|
26
|
+
queue:
|
27
|
+
shanghai: 1
|
28
|
+
shenzhen: 1
|
29
|
+
hk_us: 1
|
30
|
+
|
23
31
|
|
24
32
|
development:
|
25
33
|
<<: *default_settings
|
data/lib/cs/service/cli.rb
CHANGED
@@ -7,7 +7,7 @@ module Cs
|
|
7
7
|
end
|
8
8
|
|
9
9
|
# Cli
|
10
|
-
class Cli < Thor
|
10
|
+
class Cli < Thor # rubocop:disable ClassLength
|
11
11
|
ENVS = %w(REST_SERVER_ROOT TRADING_SERVER_ROOT RAILS_ROOT RACK_ENV).freeze
|
12
12
|
PROJECTS = %w( rest_server trading_server web).freeze
|
13
13
|
CONFIG_FILES = {
|
@@ -19,8 +19,9 @@ module Cs
|
|
19
19
|
desc 'load', '首次加载配置文件'
|
20
20
|
method_option :force, type: :boolean, aliases: '-f', desc: '强制重新加载配置文件'
|
21
21
|
def load_conf
|
22
|
+
invoke(:env)
|
22
23
|
quit if options[:force]
|
23
|
-
run_eye(
|
24
|
+
run_eye(:load, File.join(HOME_PATH, 'config/caishuo.eye'))
|
24
25
|
end
|
25
26
|
|
26
27
|
desc 'env [ENV_NAME]', '环境变量检查'
|
@@ -46,31 +47,33 @@ module Cs
|
|
46
47
|
|
47
48
|
desc 'info [PROJECT]', '查看当前运行状态'
|
48
49
|
def info(name = nil)
|
49
|
-
|
50
|
+
# invoke(:env)
|
51
|
+
run_eye(:info, name)
|
50
52
|
end
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
desc 'restart [PROJECT]', '重启项目'
|
65
|
-
def restart(name = nil)
|
66
|
-
name ||= PROJECTS * ' '
|
67
|
-
run_eye("restart #{name}")
|
53
|
+
map status: :info
|
54
|
+
|
55
|
+
{
|
56
|
+
start: '启动',
|
57
|
+
stop: '停止',
|
58
|
+
restart: '重启',
|
59
|
+
delete: '删除'
|
60
|
+
}.each do |command, name|
|
61
|
+
desc "#{command} PROJECT[,...]", "#{name}项目"
|
62
|
+
define_method(command) do |*projects|
|
63
|
+
projects = PROJECTS if projects == []
|
64
|
+
run_eye(command, *projects)
|
65
|
+
end
|
68
66
|
end
|
69
67
|
|
70
68
|
desc 'quit', '退出 cs-service'
|
71
69
|
def quit
|
72
|
-
|
73
|
-
run_eye(
|
70
|
+
stop
|
71
|
+
run_eye(:quit)
|
72
|
+
end
|
73
|
+
|
74
|
+
desc 'log [PROJECT]', '查看日志'
|
75
|
+
def log(project = nil)
|
76
|
+
run_eye(:trace, project || PROJECTS)
|
74
77
|
end
|
75
78
|
|
76
79
|
desc 'help [COMMAND]', '帮助'
|
@@ -96,8 +99,9 @@ module Cs
|
|
96
99
|
end
|
97
100
|
end
|
98
101
|
|
99
|
-
def run_eye(args
|
100
|
-
|
102
|
+
def run_eye(command, *args)
|
103
|
+
ENV['CURRENT_PWD'] = current_root
|
104
|
+
::Eye::Cli.new.send(command, *args)
|
101
105
|
end
|
102
106
|
|
103
107
|
# 查找有效的配置文件
|
data/lib/cs/service/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cs-service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- wangchangming
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- config/processes/project.rb
|
102
102
|
- config/processes/puma.rb
|
103
103
|
- config/processes/realtime.rb
|
104
|
+
- config/processes/rt_client.rb
|
104
105
|
- config/processes/scheduler.rb
|
105
106
|
- config/processes/sneaker.rb
|
106
107
|
- config/processes/worker.rb
|
@@ -125,9 +126,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
126
|
version: '0'
|
126
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
128
|
requirements:
|
128
|
-
- - "
|
129
|
+
- - ">"
|
129
130
|
- !ruby/object:Gem::Version
|
130
|
-
version:
|
131
|
+
version: 1.3.1
|
131
132
|
requirements: []
|
132
133
|
rubyforge_project:
|
133
134
|
rubygems_version: 2.4.5
|