Fix REXML Exception when using Unicorn or Passenger with XmlRPC. Add XML RPC events logging. Refactor. Improve after_rollback callback. Refs #2162
This commit is contained in:
parent
d8c491f6e1
commit
0c3a044f81
2
Gemfile
2
Gemfile
|
@ -29,7 +29,7 @@ gem 'unicorn'
|
|||
|
||||
# XML-RPC support
|
||||
# gem 'actionwebservice' #, :git => 'git://github.com/ywen/actionwebservice.git'
|
||||
gem "rails-xmlrpc"
|
||||
gem "rails-xmlrpc", :git => 'git://github.com/chipiga/rails-xmlrpc.git'
|
||||
|
||||
group :production do
|
||||
gem "airbrake"
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
GIT
|
||||
remote: git://github.com/chipiga/rails-xmlrpc.git
|
||||
revision: 3cf79e062c65447809209724a0cb8d1ea5af2e57
|
||||
specs:
|
||||
rails-xmlrpc (0.3.1)
|
||||
|
||||
GIT
|
||||
remote: git@github.com:warpc/gitolito.git
|
||||
revision: 8608b9bdfd33e961d9f9d71dd594e62780c074f6
|
||||
|
@ -189,7 +195,6 @@ GEM
|
|||
activesupport (= 3.0.10)
|
||||
bundler (~> 1.0)
|
||||
railties (= 3.0.10)
|
||||
rails-xmlrpc (0.3.2)
|
||||
rails3-generators (0.17.4)
|
||||
railties (>= 3.0.0)
|
||||
railties (3.0.10)
|
||||
|
@ -280,7 +285,7 @@ DEPENDENCIES
|
|||
paperclip (~> 2.3)
|
||||
pg (~> 0.11.0)
|
||||
rails (= 3.0.10)
|
||||
rails-xmlrpc
|
||||
rails-xmlrpc!
|
||||
rails3-generators
|
||||
rspec-rails (~> 2.7.0)
|
||||
ruby-debug
|
||||
|
|
|
@ -3,6 +3,7 @@ class RpcController < ApplicationController
|
|||
|
||||
before_filter :authenticate_user!
|
||||
before_filter :check_global_access
|
||||
before_filter lambda { EventLog.current_controller = self }, :only => :xe_index # should be after auth callback
|
||||
|
||||
## Usage example:
|
||||
#
|
||||
|
@ -11,27 +12,31 @@ class RpcController < ApplicationController
|
|||
# client.call("project_versions", 1)
|
||||
|
||||
def platforms
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :message => 'список платформ')
|
||||
return Platform.select('id, unixname').where("platform_type = ?", 'main').map(&:attributes)
|
||||
end
|
||||
|
||||
def user_projects
|
||||
current_user.projects.map{|pr| { :id => pr.id, :unixname => pr.unixname } }
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :message => 'список пользовательских проектов')
|
||||
current_user.projects.map{|p| { :id => p.id, :unixname => p.unixname } }
|
||||
end
|
||||
|
||||
def project_versions id
|
||||
pr = Project.findby_id(id)
|
||||
return nil if pr.blank?
|
||||
pr.project_versions.collect { |tag| [tag.name.gsub(/^\w+\./, ""), tag.name] }.select { |pv| pv[1] =~ /^v\./ }
|
||||
p = Project.find_by_id(id)
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :object => p, :message => "список версий")
|
||||
return nil if p.blank?
|
||||
p.project_versions.collect {|tag| [tag.name.gsub(/^\w+\./, ""), tag.name]}.select {|pv| pv[1] =~ /^v\./}
|
||||
end
|
||||
|
||||
def build_status id
|
||||
BuildList.find_by_id(id).try(:status)
|
||||
bl = BuildList.find_by_id(id)
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :object => bl, :message => 'статус сборки')
|
||||
bl.try(:status) || 'not found'
|
||||
end
|
||||
|
||||
def build_packet project_id, repo_id
|
||||
# TODO: build packet
|
||||
# p = Project.find_by_id(project_id); r = Repository.find_by_id(repo_id)
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :message => 'сборка пакета')
|
||||
'unknown' # TODO: build packet
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
|
|
@ -18,9 +18,9 @@ class EventLog < ActiveRecord::Base
|
|||
create(attributes) do |el|
|
||||
el.user = current_controller.current_user
|
||||
el.ip = current_controller.request.remote_ip
|
||||
el.protocol = 'web' # TODO pass protocol through controller or calculate by name
|
||||
el.controller = current_controller.class.to_s
|
||||
el.action = current_controller.action_name
|
||||
el.protocol = (el.controller == 'RpcController' ? 'api' : 'web')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class Project < ActiveRecord::Base
|
|||
after_create :create_git_repo
|
||||
before_update :update_git_repo
|
||||
after_destroy :destroy_git_repo
|
||||
after_rollback lambda { destroy_git_repo rescue true }
|
||||
after_rollback lambda { destroy_git_repo rescue true if new_record? }
|
||||
|
||||
def project_versions
|
||||
#tags.collect { |tag| [tag.name, tag.name.gsub(/^\w+\./, "")] }.select { |pv| pv[0] =~ /^v\./ }
|
||||
|
|
|
@ -11,7 +11,7 @@ class ProjectToRepository < ActiveRecord::Base
|
|||
|
||||
after_create lambda { project.xml_rpc_create(repository) }
|
||||
after_destroy lambda { project.xml_rpc_destroy(repository) }
|
||||
after_rollback lambda { project.xml_rpc_destroy(repository) rescue true }
|
||||
after_rollback lambda { project.xml_rpc_destroy(repository) rescue true if new_record? }
|
||||
|
||||
#def path
|
||||
# build_path(project.unixname)
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
require 'rubygems'
|
||||
require 'xmlrpc/client'
|
||||
require 'ap' # awesome_print
|
||||
require 'awesome_print'
|
||||
|
||||
# Please correctly fill following vars
|
||||
@host = 'localhost'
|
||||
@port = 3000
|
||||
@user = 'user@email'
|
||||
@password = ''
|
||||
@user = 'pchipiga@ya.ru'
|
||||
@password = '123456'
|
||||
|
||||
puts 'PLATFORMS'
|
||||
client = XMLRPC::Client.new(@host, '/api/xmlrpc', @port, nil, nil, @user, @password, false, 900)
|
||||
|
|
|
@ -10,6 +10,7 @@ ru:
|
|||
'devise/sessions_controller': 'Аутентификация пользователей'
|
||||
'devise/passwords_controller': 'Восстановление пароля'
|
||||
'users/omniauth_callbacks_controller': 'Внешняя аутентификация пользователей'
|
||||
rpc_controller: XML RPC
|
||||
actions:
|
||||
'devise/sessions_controller':
|
||||
create: 'вход'
|
||||
|
@ -22,6 +23,8 @@ ru:
|
|||
build_lists_controller:
|
||||
cancel: 'сборка отменена'
|
||||
publish: 'сборка опубликована'
|
||||
rpc_controller:
|
||||
xe_index: запрос
|
||||
create: 'создано'
|
||||
update: 'обновлено'
|
||||
destroy: 'удалено'
|
||||
|
|
|
@ -273,9 +273,8 @@ ActiveRecord::Schema.define(:version => 20111029150934) do
|
|||
t.string "name"
|
||||
t.string "email", :default => "", :null => false
|
||||
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
||||
t.string "password_salt", :default => "", :null => false
|
||||
t.string "reset_password_token"
|
||||
t.string "remember_token"
|
||||
t.datetime "reset_password_sent_at"
|
||||
t.datetime "remember_created_at"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
|
|
Loading…
Reference in New Issue