add Stop action and time_living for building ISO

This commit is contained in:
Vokhmin Alexey V 2012-11-12 17:22:19 +04:00
parent d2871afaff
commit 259eeaecfc
11 changed files with 64 additions and 9 deletions

View File

@ -14,6 +14,7 @@ class Platforms::ProductBuildListsController < Platforms::BaseController
product = @product_build_list.product
@product_build_list.params = product.params
@product_build_list.main_script = product.main_script
@product_build_list.time_living = product.time_living
@product_build_list.project = product.project
unless @product_build_list.project
flash[:error] = t('flash.product_build_list.no_project')
@ -24,13 +25,19 @@ class Platforms::ProductBuildListsController < Platforms::BaseController
def show
end
def stop
@product_build_list.stop
flash[:notice] = t('flash.product_build_list.will_be_stopped')
redirect_to platform_product_product_build_list_path(@platform, @product, @product_build_list)
end
def log
@log = Resque.redis.get("abfworker::iso-worker-#{@product_build_list.id}") || ''
respond_to do |format|
format.json {
render :json => {
:log => @log,
:building => @product_build_list.build_started? }
:log => @product_build_list.log,
:building => @product_build_list.build_started?
}
}
end
end

View File

@ -8,7 +8,7 @@ class Product < ActiveRecord::Base
scope :recent, order("name ASC")
attr_accessible :name, :description, :project_id, :main_script, :params
attr_accessible :name, :description, :project_id, :main_script, :params, :time_living
attr_readonly :platform_id
def full_clone(attrs = {})

View File

@ -21,11 +21,15 @@ class ProductBuildList < ActiveRecord::Base
belongs_to :project
validates :product_id, :status, :project_id, :main_script, :presence => true
validates :product_id,
:status,
:project_id,
:main_script,
:time_living, :presence => true
validates :status, :inclusion => { :in => [BUILD_STARTED, BUILD_COMPLETED, BUILD_FAILED] }
attr_accessor :base_url
attr_accessible :status, :base_url, :branch, :project_id, :main_script, :params, :project_version, :commit_hash
attr_accessible :status, :base_url, :branch, :project_id, :main_script, :params, :project_version, :commit_hash, :time_living
attr_readonly :product_id
serialize :results, Array
@ -64,6 +68,18 @@ class ProductBuildList < ActiveRecord::Base
[BUILD_COMPLETED, BUILD_FAILED].include? status
end
def log
Resque.redis.get("abfworker::iso-worker-#{id}") || ''
end
def stop
Resque.redis.setex(
"abfworker::iso-worker-#{id}::live-inspector",
60,
'USR1' # Immediately kill child but don't exit
)
end
protected
def xml_rpc_create
@ -81,6 +97,7 @@ class ProductBuildList < ActiveRecord::Base
# :srcpath => 'http://dl.dropbox.com/u/945501/avokhmin-test-iso-script-5d9b463d4e9c06ea8e7c89e1b7ff5cb37e99e27f.tar.gz',
:srcpath => srcpath,
:params => params,
:time_living => time_living,
:main_script => main_script
}
Resque.push(

View File

@ -20,6 +20,10 @@
.rightlist= f.text_field :params
.both
.leftlist= f.label :time_living, t("activerecord.attributes.product_build_list.time_living"), :class => :label
.rightlist= f.text_field :time_living
.both
= f.submit t("layout.projects.build_button")
%br

View File

@ -36,11 +36,18 @@
.rightlist= pbl.params
.both
.leftlist= t("activerecord.attributes.product_build_list.time_living")
.rightlist= pbl.time_living
.both
.leftlist= t("activerecord.attributes.product_build_list.notified_at")
.rightlist= l(pbl.updated_at, :format => :long)
.both
- if pbl.build_started?
.leftlist= t("layout.product_build_lists.action")
.rightlist= link_to t("layout.product_build_lists.stop"), stop_platform_product_product_build_list_path(pbl.product.platform, pbl.product, pbl)
.both
= render 'shared/log', { :build_started => true, :get_log_path => log_platform_product_product_build_list_path(pbl.product.platform, pbl.product, pbl) }
%h3= t("layout.product_build_lists.results")

View File

@ -18,6 +18,10 @@
.rightlist= f.text_field :params
.both
.leftlist= f.label :time_living, t("activerecord.attributes.product_build_list.time_living"), :class => :label
.rightlist= f.text_field :time_living
.both
.button_block
= submit_tag t("layout.save")
%span.text_button_padding= t("layout.or")

View File

@ -8,6 +8,7 @@ en:
results_folder: all files from this folder will be uploaded into the file-store
archives_folder: this folder will be archived and uploaded into the file-store
delete: Delete
stop: Stop
action: Action
id_search: 'Id search'
new: New build
@ -40,6 +41,7 @@ en:
project_version: Version
main_script: Main script
params: Params for running script
time_living: Max time for building (in minutes)
product_build_list/results:
file_name: File name
sha1: SHA1
@ -49,3 +51,4 @@ en:
no_project: Project for build should be exist
delete: Product build list deleted
delete_error: Unable to delete product build list
will_be_stopped: Build will be stopped

View File

@ -8,6 +8,7 @@ ru:
results_folder: все файлы из этой папки будут загружены на file-store
archives_folder: эта папка будет заархивирована и загружена на file-store
delete: Удалить
stop: Остановить
action: Действие
id_search: 'Поиск по Id'
new: Новая сборка
@ -40,6 +41,7 @@ ru:
project_version: Версия
main_script: Основной скрипт
params: Параметры для запуска скрипта
time_living: Максимальное время сборки (в минутах)
product_build_list/results:
file_name: Имя файла
sha1: SHA1
@ -49,4 +51,4 @@ ru:
no_project: Проект для сборки должен присутствовать
delete: Сборочный лист продукта удален
delete_error: Не удалось удалить cборочный лист продукта
will_be_stopped: Сборка будет остановлена

View File

@ -146,7 +146,10 @@ Rosa::Application.routes.draw do
resources :key_pairs, :only => [:create, :index, :destroy]
resources :products do
resources :product_build_lists, :only => [:create, :destroy, :new, :show] do
member { get :log }
member {
get :log
get :stop
}
end
collection { get :autocomplete_project }
end

View File

@ -24,6 +24,9 @@ class IntegrateNewIsoBuilderWithProducts < ActiveRecord::Migration
add_column :products, :main_script, :string
add_column :product_build_lists, :results, :text
add_column :products, :time_living, :integer
add_column :product_build_lists, :time_living, :integer
end
def down
@ -51,5 +54,8 @@ class IntegrateNewIsoBuilderWithProducts < ActiveRecord::Migration
remove_column :products, :main_script
remove_column :product_build_lists, :results
remove_column :product_build_lists, :time_living
remove_column :products, :time_living
end
end

View File

@ -287,6 +287,7 @@ ActiveRecord::Schema.define(:version => 20121106113338) do
t.string "params"
t.string "main_script"
t.text "results"
t.integer "time_living"
end
add_index "product_build_lists", ["product_id"], :name => "index_product_build_lists_on_product_id"
@ -300,6 +301,7 @@ ActiveRecord::Schema.define(:version => 20121106113338) do
t.integer "project_id"
t.string "params"
t.string "main_script"
t.integer "time_living"
end
create_table "project_imports", :force => true do |t|