Permalink
Browse files

Minor misc changes to enable new-style staging plugins

Allow new-style staging plugins to be used in the stager by adding them
to the 'enabled_framework_plugins' property. Enable node support using
the new style plugins.

Test plan:
- Deployed a node app using the new-style plugins

Change-Id: If5d79af7ce456d1d0f602e7194d8761aac823e56
  • Loading branch information...
mpage
mpage committed Nov 15, 2011
1 parent 04e38fe commit c092a1df37fea820354328861d93c60b80d861f4
View
@@ -1177,7 +1177,7 @@ def stop_droplet(instance)
if instance[:pid] || [:STARTING, :RUNNING].include?(instance[:state])
instance[:state] = :STOPPED unless instance[:state] == :CRASHED
instance[:state_timestamp] = Time.now.to_i
- stop_cmd = File.join(instance[:dir], 'stop')
+ stop_cmd = "cd #{instance[:dir]} && ./stop"
stop_cmd = "su -c #{stop_cmd} #{username}" if @secure
stop_cmd = "#{stop_cmd} 2> /dev/null"
View
@@ -13,6 +13,9 @@ gem 'vcap_staging', '>= 0.1.11'
gem 'vcap_stager_ipc', '= 0.0.2'
gem 'vcap_cloud_controller_ipc'
+# Plugins
+gem 'vcap_node_staging_plugin', :require => 'vcap/plugins/staging/node/export'
+
group :test do
gem 'rspec'
gem 'sinatra'
View
@@ -32,7 +32,7 @@ GEM
sinatra (1.2.6)
rack (~> 1.1)
tilt (>= 1.2.2, < 2.0)
- thin (1.2.11)
+ thin (1.3.0)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
@@ -45,9 +45,13 @@ GEM
logging (>= 1.5.0)
nats
posix-spawn
+ rake
thin
+ vcap_logging
yajl-ruby
vcap_logging (0.1.1)
+ vcap_node_staging_plugin (0.0.1)
+ rake
vcap_stager_ipc (0.0.2)
eventmachine
rake
@@ -79,6 +83,7 @@ DEPENDENCIES
vcap_cloud_controller_ipc
vcap_common (>= 1.0.0)
vcap_logging (>= 0.1.1)
+ vcap_node_staging_plugin
vcap_stager_ipc (= 0.0.2)
vcap_staging (>= 0.1.11)
webmock
View
@@ -15,7 +15,7 @@ done
# Execute the framework stop script
if [ -e "./framework_stop" ]
then
- ./framework_stop
+ ./framework_stop $@
fi
# Just to be safe
View
@@ -1,7 +1,9 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
-require 'bundler/setup'
+require 'bundler'
+Bundler.require
+
require 'yaml'
require 'vcap/plugin_registry'
@@ -15,7 +17,7 @@ if ARGV.length != 1
exit 1
end
-task = VCAP::PluginRunner.deserialize_task(ARGV[0])
+task = VCAP::Stager::PluginRunner.deserialize_task(ARGV[0])
begin
if task['opts']['config_dir']
VCAP::PluginRegistry.configure_plugins(task['opts']['config_dir'])
@@ -37,5 +39,5 @@ rescue => e
YAML.dump(e, f)
end
end
- exit 1
+ raise e
end
View
@@ -6,4 +6,6 @@ nats_uri: nats://127.0.0.1:4222
max_staging_duration: 120
max_active_tasks: 10
queues: ['vcap.staging.linux']
-secure: false
+secure: false
+enabled_framework_plugins:
+ node: vcap_node_staging_plugin
@@ -26,8 +26,11 @@ class VCAP::Stager::Config < VCAP::Config
optional(:dirs) => {
optional(:manifests) => String, # Where all of the staging manifests live
optional(:tmp) => String, # Default is /tmp
+ optional(:plugin_configs) => String, # Where the staging plugin configs live.
},
+ optional(:enabled_framework_plugins) => Hash, # Optional map of framework => new style staging plugin
+
:secure => VCAP::JsonSchema::BoolSchema.new,
optional(:index) => Integer, # Component index (stager-0, stager-1, etc)
@@ -40,6 +43,7 @@ class VCAP::Stager::Config < VCAP::Config
def self.from_file(*args)
config = super(*args)
+ config[:enabled_framework_plugins] ||= {}
config[:dirs] ||= {}
config[:dirs][:manifests] ||= StagingPlugin::DEFAULT_MANIFEST_ROOT
config[:run_plugin_path] ||= File.expand_path('../../../../bin/run_plugin', __FILE__)
@@ -63,6 +63,8 @@ def initialize(app_id, props, download_uri, upload_uri, cc_info, response, opts=
@manifest_dir = option(opts, :manifest_dir)
@tmpdir_base = opts[:tmpdir]
@user = opts[:user]
+ @plugin_config_dir = opts[:plugin_config_dir]
+ @plugins = VCAP::Stager.config[:enabled_framework_plugins]
@download_app_helper_path = option(opts, :download_app_helper_path)
@upload_droplet_helper_path = option(opts, :upload_droplet_helper_path)
end
@@ -93,7 +95,10 @@ def perform(&callback)
download_app(dirs[:unstaged], dirs[:base])
task_logger.info("Staging application")
- if @app_props['plugins']
+ # Temporary hack until all plugins are converted
+ new_style_plugin = @plugins[@app_props['framework'].to_sym]
+ if new_style_plugin
+ @app_props['plugins'] = {new_style_plugin => {}}
run_plugins(dirs[:unstaged], dirs[:staged], dirs[:base])
else
run_staging_plugin(dirs[:unstaged], dirs[:staged], dirs[:base], task_logger)
@@ -253,6 +258,7 @@ def run_staging_plugin(src_dir, dst_dir, work_dir, task_logger)
def run_plugins(src_dir, dst_dir, base_dir)
task_path = File.join(base_dir, 'task')
task_opts = {
+ 'config_dir' => @plugin_config_dir,
'log_path' => File.join(base_dir, 'staging.log'),
'error_path' => File.join(base_dir, 'plugin_runner_error'),
}
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit c092a1d

Please sign in to comment.