sails 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -16
- data/CHANGELOG.md +13 -0
- data/Gemfile.lock +2 -2
- data/README.md +37 -11
- data/lib/sails/base.rb +225 -208
- data/lib/sails/cli.rb +13 -14
- data/lib/sails/config.rb +5 -5
- data/lib/sails/console.rb +9 -9
- data/lib/sails/daemon.rb +72 -27
- data/lib/sails/log_subscriber.rb +40 -0
- data/lib/sails/rails.rb +5 -1
- data/lib/sails/service/base.rb +8 -8
- data/lib/sails/service/callbacks.rb +2 -3
- data/lib/sails/service/interface.rb +34 -27
- data/lib/sails/service.rb +2 -2
- data/lib/sails/tasks.rb +61 -0
- data/lib/sails/templates/Gemfile +4 -4
- data/lib/sails/templates/Rakefile.tt +1 -41
- data/lib/sails/templates/app/services/application_service.rb.tt +6 -2
- data/lib/sails/templates/app/services/gen-rb/%app_name%.rb.tt +78 -3
- data/lib/sails/templates/app/services/gen-rb/%app_name%_constants.rb.tt +11 -0
- data/lib/sails/templates/app/services/gen-rb/%app_name%_types.rb.tt +46 -0
- data/lib/sails/templates/config/application.rb.tt +8 -8
- data/lib/sails/templates/config/{database.yml → database.yml.tt} +2 -5
- data/lib/sails/templates/config/initializers/active_record.rb +6 -0
- data/lib/sails/templates/config/locales/rails.zh-CN.yml +5 -5
- data/lib/sails/templates/config/locales/zh-CN.yml +1 -2
- data/lib/sails/templates/lib/tasks/client.rake.tt +25 -0
- data/lib/sails/version.rb +2 -2
- data/lib/sails.rb +12 -6
- data/sails.gemspec +1 -1
- data/spec/cli_spec.rb +6 -6
- data/spec/dummy/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/tmp/.keep +0 -0
- data/spec/dummy/tmp/cache/.keep +0 -0
- data/spec/dummy/tmp/pids/.keep +0 -0
- data/spec/rails_spec.rb +1 -0
- data/spec/sails_spec.rb +39 -11
- data/spec/spec_helper.rb +1 -1
- data/spec/support/service_support.rb +2 -2
- metadata +28 -8
- data/lib/sails/templates/Gemfile.lock +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9752501c98161e8b95d109743e4f9ce2091d0127
|
4
|
+
data.tar.gz: 24a4dcca7f3748da76c715f4d97cb46857308d0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 703defe29c4488dfce4147d86416cea85c1d5834cc6b10c535cfc24f2ad0c62bd6f6463d3618b394919302e35bffdefd9daabdcfe3023d1fd78ded56a0ecfa1a
|
7
|
+
data.tar.gz: 90f1944aed8c06b9c98c49f2fc0602bc189a7b02ab326d5b2fa623b40f3381967d65a966d9a252b02aa3d5cc59439a9015f7f97e4bb4e0771e6e430b95210c92
|
data/.gitignore
CHANGED
@@ -9,28 +9,14 @@
|
|
9
9
|
/test/version_tmp/
|
10
10
|
/tmp/
|
11
11
|
log/*
|
12
|
-
|
13
|
-
## Specific to RubyMotion:
|
14
12
|
.dat*
|
15
|
-
.repl_history
|
16
13
|
build/
|
17
|
-
|
18
|
-
## Documentation cache and generated files:
|
19
14
|
/.yardoc/
|
20
15
|
/_yardoc/
|
21
16
|
/doc/
|
22
17
|
/rdoc/
|
23
|
-
|
24
|
-
## Environment normalisation:
|
25
18
|
/.bundle/
|
26
19
|
/lib/bundler/man/
|
27
|
-
|
28
|
-
# for a library or gem, you might want to ignore these files since the code is
|
29
|
-
# intended to run in multiple environments; otherwise, check them in:
|
30
|
-
# Gemfile.lock
|
31
|
-
# .ruby-version
|
32
|
-
# .ruby-gemset
|
33
|
-
|
34
|
-
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
35
20
|
.rvmrc
|
36
|
-
spec/dummy/log
|
21
|
+
spec/dummy/log/*.log
|
22
|
+
spec/dummy/log/*.log
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## 0.1.5
|
2
|
+
|
3
|
+
- Fix stdout error in daemon mode.
|
4
|
+
- Clear ActiveRecord connections after method call in ensure.
|
5
|
+
- Do not output exception info when raise 404.
|
6
|
+
- Add more default code with new project template.
|
7
|
+
- Add `rake client` task for thrift client connect test, and you can edit client test code in lib/tasks/client.rake.
|
8
|
+
- Move ActiveRecord migration rake tasks into Sails.
|
9
|
+
- Add `rake db:migrate:create` command to generate a new migration file.
|
10
|
+
- Add default ActiveRecord initialize code.
|
11
|
+
- Default use SQLite.
|
12
|
+
- Use ActiveSupport::Notifications to output service action logs.
|
13
|
+
|
1
14
|
## 0.1.4 / 2014-12-24
|
2
15
|
|
3
16
|
- Sails.root use Linux pwd command, to support symlink dir, for example like Capistrano's project/current path.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -41,27 +41,50 @@ $ sails start
|
|
41
41
|
You can edit Thrift IDL in `app_name.thrift`, and then generate it to ruby source code.
|
42
42
|
|
43
43
|
```
|
44
|
-
$ rake
|
44
|
+
$ rake generate
|
45
45
|
```
|
46
46
|
|
47
|
-
##
|
47
|
+
## Rake tasks
|
48
48
|
|
49
|
-
```
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
49
|
+
```bash
|
50
|
+
rake client:ping # client ping test
|
51
|
+
rake db:create # Creates the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use db:create:all to create all databases in the config)
|
52
|
+
rake db:drop # Drops the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use db:drop:all to drop all databases in the config)
|
53
|
+
rake db:fixtures:load # Load fixtures into the current environment's database
|
54
|
+
rake db:migrate # Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
|
55
|
+
rake db:migrate:create # Create new migration file
|
56
|
+
rake db:migrate:status # Display status of migrations
|
57
|
+
rake db:rollback # Rolls the schema back to the previous version (specify steps w/ STEP=n)
|
58
|
+
rake db:schema:cache:clear # Clear a db/schema_cache.dump file
|
59
|
+
rake db:schema:cache:dump # Create a db/schema_cache.dump file
|
60
|
+
rake db:schema:dump # Create a db/schema.rb file that is portable against any DB supported by AR
|
61
|
+
rake db:schema:load # Load a schema.rb file into the database
|
62
|
+
rake db:seed # Load the seed data from db/seeds.rb
|
63
|
+
rake db:setup # Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the database first)
|
64
|
+
rake db:structure:dump # Dump the database structure to db/structure.sql
|
65
|
+
rake db:structure:load # Recreate the databases from the structure.sql file
|
66
|
+
rake db:version # Retrieves the current schema version number
|
67
|
+
rake generate # Generate code from thrift IDL file
|
68
|
+
```
|
69
|
+
|
70
|
+
## Client connect to test
|
71
|
+
|
72
|
+
You can write test code in `lib/tasks/client.rake` to test your thrift methods.
|
73
|
+
|
74
|
+
And then start sails server, and run rake task to test, for example:
|
75
|
+
|
76
|
+
```bash
|
77
|
+
sails s --daemon
|
78
|
+
rake client:ping
|
57
79
|
```
|
58
80
|
|
81
|
+
|
59
82
|
## Deploy
|
60
83
|
|
61
84
|
```
|
62
85
|
$ sails s --daemon
|
63
86
|
$ ps aux
|
64
|
-
jason 2408 0.1 0.2 2648176 13532 s003 S 12:14下午 0:00.02 you_sails_app
|
87
|
+
jason 2408 0.1 0.2 2648176 13532 s003 S 12:14下午 0:00.02 you_sails_app
|
65
88
|
jason 2407 0.0 0.0 2604916 1016 s003 S 12:14下午 0:00.00 you_sails_app [master]
|
66
89
|
$ sails restart
|
67
90
|
$ sails stop
|
@@ -77,3 +100,6 @@ http://www.rubydoc.info/github/huacnlee/sails
|
|
77
100
|
- [ ] Reload without restart;
|
78
101
|
- [ ] Scaffold generator;
|
79
102
|
- [X] Multi processes;
|
103
|
+
- [ ] Default test case templates;
|
104
|
+
- [ ] Client rake task to test services;
|
105
|
+
- [ ] Write more framework test cases.
|
data/lib/sails/base.rb
CHANGED
@@ -1,244 +1,261 @@
|
|
1
|
-
Bundler.require
|
1
|
+
Bundler.require
|
2
2
|
|
3
3
|
module Sails
|
4
4
|
extend ActiveSupport::Autoload
|
5
5
|
|
6
6
|
autoload :Config
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
8
|
+
class << self
|
9
|
+
# Sails.config
|
10
|
+
#
|
11
|
+
# Configs with Sails
|
12
|
+
# For example:
|
13
|
+
#
|
14
|
+
# Sails.config.app_name
|
15
|
+
# # => returns "You App Name"
|
16
|
+
#
|
17
|
+
# Sails.config.autoload_paths
|
18
|
+
# # => returns ['app/models','app/models/concerns', 'app/workers', 'app/services'...]
|
19
|
+
#
|
20
|
+
# Sails.config.cache_store = [:dalli_store, '127.0.0.1', { pool_size: 100 }]
|
21
|
+
# Sails.config.i18n.default_locale = 'zh-CN'
|
22
|
+
#
|
23
|
+
def config
|
24
|
+
return @config if defined?(@config)
|
25
|
+
@config = Config.new.config
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
28
|
+
# Sails.cache
|
29
|
+
#
|
30
|
+
# An abstract cache store class. There are multiple cache store
|
31
|
+
# implementations, each having its own additional features. See the classes
|
32
|
+
# under the ActiveSupport::Cache module, e.g.
|
33
|
+
# ActiveSupport::Cache::MemCacheStore. MemCacheStore is currently the most
|
34
|
+
# popular cache store for large production websites.
|
35
|
+
#
|
36
|
+
# Some implementations may not support all methods beyond the basic cache
|
37
|
+
# methods of +fetch+, +write+, +read+, +exist?+, and +delete+.
|
38
|
+
#
|
39
|
+
# ActiveSupport::Cache::Store can store any serializable Ruby object.
|
40
|
+
#
|
41
|
+
# Sails.cache.read('city') # => nil
|
42
|
+
# Sails.cache.write('city', "Duckburgh")
|
43
|
+
# Sails.cache.read('city') # => "Duckburgh"
|
44
|
+
#
|
45
|
+
# Keys are always translated into Strings and are case sensitive. When an
|
46
|
+
# object is specified as a key and has a +cache_key+ method defined, this
|
47
|
+
# method will be called to define the key. Otherwise, the +to_param+
|
48
|
+
# method will be called. Hashes and Arrays can also be used as keys. The
|
49
|
+
# elements will be delimited by slashes, and the elements within a Hash
|
50
|
+
# will be sorted by key so they are consistent.
|
51
|
+
#
|
52
|
+
# Sails.cache.read('city') == Sails.cache.read(:city) # => true
|
53
|
+
#
|
54
|
+
# Nil values can be cached.
|
55
|
+
def cache
|
56
|
+
return @cache if defined?(@cache)
|
57
|
+
@cache = ActiveSupport::Cache.lookup_store(self.config.cache_store)
|
58
|
+
end
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
60
|
+
# Sails.root
|
61
|
+
#
|
62
|
+
# This method returns a Pathname object which handles paths starting with a / as absolute (starting from the root of the filesystem). Compare:
|
63
|
+
#
|
64
|
+
# For example:
|
65
|
+
# >> Sails.root
|
66
|
+
# => #<Pathname:/some/path/to/project>
|
67
|
+
# >> Sails.root + "file"
|
68
|
+
# => #<Pathname:/some/path/to/project/file>
|
69
|
+
#
|
70
|
+
def root
|
71
|
+
return @root if defined?(@root)
|
72
|
+
path = `pwd -L`.sub(/\n/,'') rescue Dir.pwd
|
73
|
+
@root ||= Pathname.new(path)
|
74
|
+
end
|
74
75
|
|
75
|
-
|
76
|
-
|
77
|
-
|
76
|
+
def root=(root)
|
77
|
+
@root = Pathname.new(root)
|
78
|
+
end
|
78
79
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
80
|
+
# Sails.env
|
81
|
+
#
|
82
|
+
# returns a string representing the current Sails environment.
|
83
|
+
# This will read from ENV['RAILS_ENV'] like Rails
|
84
|
+
#
|
85
|
+
# For example:
|
86
|
+
#
|
87
|
+
# Sails.env # in development mode
|
88
|
+
# => "development"
|
89
|
+
# Sails.env.development?
|
90
|
+
# => true
|
91
|
+
#
|
92
|
+
def env
|
93
|
+
@env ||= ActiveSupport::StringInquirer.new(ENV['RAILS_ENV'].presence || 'development')
|
94
|
+
end
|
94
95
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
end
|
96
|
+
# Sails.logger
|
97
|
+
#
|
98
|
+
# returns a Logger class
|
99
|
+
# For example:
|
100
|
+
#
|
101
|
+
# Sails.logger.info "Hello world"
|
102
|
+
# Sails.logger.error "Hello world"
|
103
|
+
#
|
104
|
+
def logger
|
105
|
+
return @logger if defined?(@logger)
|
106
|
+
@logger = Logger.new(logger_path)
|
107
|
+
@logger.formatter = proc { |severity, datetime, progname, msg|
|
108
|
+
"#{msg}\n"
|
109
|
+
}
|
110
|
+
@logger
|
111
|
+
end
|
112
112
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
$:.unshift self.root.join("lib")
|
113
|
+
def logger_path
|
114
|
+
@logger_path ||= Sails.root.join("log/#{self.env}.log")
|
115
|
+
end
|
117
116
|
|
118
|
-
|
117
|
+
def init
|
118
|
+
# init root
|
119
|
+
return false if @inited == true
|
120
|
+
$:.unshift self.root.join("lib")
|
119
121
|
|
120
|
-
|
122
|
+
self.root
|
123
|
+
self.check_create_dirs
|
121
124
|
|
122
|
-
|
123
|
-
if File.exist?(env_file)
|
124
|
-
require env_file
|
125
|
-
end
|
125
|
+
ActiveSupport::Dependencies.autoload_paths += Sails.config.autoload_paths
|
126
126
|
|
127
|
-
|
127
|
+
env_file = self.root.join('config/environments/',Sails.env + ".rb")
|
128
|
+
if File.exist?(env_file)
|
129
|
+
require env_file
|
130
|
+
end
|
128
131
|
|
129
|
-
|
130
|
-
@inited = true
|
131
|
-
end
|
132
|
+
require "sails/service"
|
132
133
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
#
|
137
|
-
# for example:
|
138
|
-
#
|
139
|
-
# class UsersService < Sails::Service::Base
|
140
|
-
# def check_name_exist?(name)
|
141
|
-
# User.check_name_exist?(name)
|
142
|
-
# end
|
143
|
-
# end
|
144
|
-
#
|
145
|
-
# class UsersServiceTest
|
146
|
-
# def test_check_name_exist?
|
147
|
-
# assert_equal(Sails.service.check_name_exist?(name), true)
|
148
|
-
# end
|
149
|
-
# end
|
150
|
-
#
|
151
|
-
def self.service
|
152
|
-
@service ||= Sails::Service::Interface.new
|
153
|
-
end
|
134
|
+
self.load_initialize
|
135
|
+
@inited = true
|
136
|
+
end
|
154
137
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
138
|
+
# Sails.service
|
139
|
+
#
|
140
|
+
# return a instance of Sails Service layer
|
141
|
+
#
|
142
|
+
# for example:
|
143
|
+
#
|
144
|
+
# class UsersService < Sails::Service::Base
|
145
|
+
# def check_name_exist?(name)
|
146
|
+
# User.check_name_exist?(name)
|
147
|
+
# end
|
148
|
+
# end
|
149
|
+
#
|
150
|
+
# class UsersServiceTest
|
151
|
+
# def test_check_name_exist?
|
152
|
+
# assert_equal(Sails.service.check_name_exist?(name), true)
|
153
|
+
# end
|
154
|
+
# end
|
155
|
+
#
|
156
|
+
def service
|
157
|
+
@service ||= Sails::Service::Interface.new
|
162
158
|
end
|
163
|
-
return true
|
164
|
-
end
|
165
159
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
160
|
+
# Force reload Sails cache classes in config.autoload_paths
|
161
|
+
def reload!(opts = {})
|
162
|
+
force = opts[:force] || false
|
163
|
+
if force || config.cache_classes == false
|
164
|
+
# @service = nil
|
165
|
+
ActiveSupport::Dependencies.clear
|
166
|
+
# reload_server!
|
167
|
+
end
|
168
|
+
true
|
169
|
+
end
|
170
|
+
|
171
|
+
def reload_server!
|
172
|
+
if @server
|
173
|
+
new_processor = config.processor.new(self.service)
|
174
|
+
@server.instance_variable_set(:@processor, new_processor)
|
175
|
+
end
|
170
176
|
end
|
171
|
-
end
|
172
177
|
|
173
|
-
|
174
|
-
|
178
|
+
def start!(type)
|
179
|
+
logger.info "ENV: #{Sails.env}"
|
175
180
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
+
@server_type = type
|
182
|
+
if @server_type == "thread"
|
183
|
+
start_thread_pool_server!
|
184
|
+
else
|
185
|
+
start_non_blocking_server!
|
186
|
+
end
|
181
187
|
end
|
182
|
-
end
|
183
188
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
189
|
+
def thrift_protocol_class
|
190
|
+
case config.protocol
|
191
|
+
when :compact
|
192
|
+
return ::Thrift::CompactProtocolFactory
|
193
|
+
when :json
|
194
|
+
return ::Thrift::JsonProtocolFactory
|
195
|
+
else
|
196
|
+
return ::Thrift::BinaryProtocolFactory
|
197
|
+
end
|
192
198
|
end
|
193
|
-
end
|
194
199
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
200
|
+
# Start Thrift Server with Threaded mode
|
201
|
+
#
|
202
|
+
def start_thread_pool_server!
|
203
|
+
transport = ::Thrift::ServerSocket.new(nil, config.thread_port)
|
204
|
+
transport_factory = ::Thrift::BufferedTransportFactory.new
|
205
|
+
protocol_factory = thrift_protocol_class.new
|
206
|
+
processor = config.processor.new(self.service)
|
207
|
+
@server = ::Thrift::ThreadPoolServer.new(processor, transport, transport_factory, protocol_factory, config.thread_size)
|
208
|
+
|
209
|
+
logger.info "Boot on: #{Sails.root}"
|
210
|
+
logger.info "[#{Time.now}] Starting the Sails with ThreadPool size: #{Setting.pool_size}..."
|
211
|
+
logger.info "serve: 127.0.0.1:#{config.thread_port}"
|
212
|
+
|
213
|
+
begin
|
214
|
+
@server.serve
|
215
|
+
rescue => e
|
216
|
+
puts "Start thrift server exception! \n #{e.inspect}"
|
217
|
+
puts e.backtrace
|
218
|
+
end
|
213
219
|
end
|
214
|
-
end
|
215
220
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
221
|
+
# Start Thrift Server with Event drive mode
|
222
|
+
def start_non_blocking_server!
|
223
|
+
transport = ::Thrift::ServerSocket.new(nil, config.port)
|
224
|
+
transport_factory = ::Thrift::FramedTransportFactory.new
|
225
|
+
protocol_factory = thrift_protocol_class.new
|
226
|
+
processor = config.processor.new(self.service)
|
227
|
+
@server = ::Thrift::NonblockingServer.new(processor, transport, transport_factory, protocol_factory, config.thread_size)
|
228
|
+
|
229
|
+
logger.info "Boot on: #{Sails.root}"
|
230
|
+
logger.info "[#{Time.now}] Starting the Sails with NonBlocking..."
|
231
|
+
logger.info "Protocol: #{thrift_protocol_class.name}"
|
232
|
+
logger.info "serve: 127.0.0.1:#{config.port}"
|
233
|
+
|
234
|
+
begin
|
235
|
+
@server.serve
|
236
|
+
rescue => e
|
237
|
+
puts "Start thrift server exception! \n #{e.inspect}"
|
238
|
+
puts e.backtrace
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
def load_initialize
|
243
|
+
Dir["#{Sails.root}/config/initializers/*.rb"].each do |f|
|
244
|
+
require f
|
245
|
+
end
|
234
246
|
end
|
235
|
-
end
|
236
247
|
|
237
|
-
|
238
|
-
|
239
|
-
|
248
|
+
def check_create_dirs
|
249
|
+
%w(log tmp tmp/cache tmp/pids).each do |name|
|
250
|
+
if not Dir.exist? Sails.root.join(name)
|
251
|
+
require "fileutils"
|
252
|
+
dir_path = Sails.root.join(name)
|
253
|
+
FileUtils.mkdir_p dir_path
|
254
|
+
FileUtils.touch [dir_path,".keep"].join("/")
|
255
|
+
end
|
256
|
+
end
|
240
257
|
end
|
241
258
|
end
|
242
259
|
end
|
243
260
|
|
244
|
-
Sails.init
|
261
|
+
Sails.init
|