Skip to content
36 changes: 1 addition & 35 deletions bin/release
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,5 @@ require 'java_buildpack/buildpack'

app_dir = ARGV[0]

output = JavaBuildpack::Buildpack.with_buildpack(app_dir, 'Release failed with exception %s', &:release)
#logger = JavaBuildpack::Buildpack.logger



#if @droplet.environment_variables['HOT_SWAP_AGENT'] == 'true'
#logger.debug 'Activating appcontroller!'
#logger.debug ("output: "+ output)
app_controller_exe = "/home/vcap/app/.java-buildpack/hotswap_agent/lib/appcontroller"
jdb_exe = "/home/vcap/app/.java-buildpack/hotswap_agent/lib/sc_jdb"

port = "8080" #@droplet.environment_variables['PORT'].first

devUtils =
{
:server_port => ":8080", :jdb_path => "#{jdb_exe}", :jdb_debug_path => "jdb",
:start => "sleep 5000", :app_url => "http://localhost:3000"
}
strDevUtils = devUtils.to_json.gsub! "\"", "\\\""
output.sub! "http.port=$PORT", "http.port=3000"


inx = output.index('web:')
webStr = output[inx+6..output.length-3]
webStr = webStr.delete("\r\n")
webStr = webStr.delete("\n")
webStr = webStr.delete("\r")
runCmd = Base64.encode64("PORT=3000 " + webStr).delete("\n")

output = output[0..inx-1] + "web: 'DEV_UTILS=\"#{strDevUtils}\" #{app_controller_exe} -startCmd #{runCmd} '"
#output.sub! "web: '", "web: 'CFPORT=$PORT PORT=3000 #{app_controller_exe} -jdbPath #{jdb_exe} & CFPORT=$PORT PORT=3000 "
#output.sub! "web: '", "web: 'export CFPORT=$PORT && export PORT=3000 && curl -s https://github.com/ariel-bentu/java-buildpack/raw/master/appcontroller.tar.gz | tar xfpz - && ./appcontroller & "
#end


output = JavaBuildpack::Buildpack.with_buildpack(app_dir, 'Release failed with exception %s', &:dev_release)
puts output
43 changes: 43 additions & 0 deletions lib/java_buildpack/buildpack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,49 @@ def release

payload
end

def dev_release
container = component_detection('container', @containers, true).first
no_container unless container

commands = []
commands << component_detection('JRE', @jres, true).first.release

component_detection('framework', @frameworks, false).map(&:release)

commands << container.release

commands.insert 0, @java_opts.as_env_var
command = commands.flatten.compact.join(' && ')

app_controller_exe = "/home/vcap/app/.java-buildpack/hotswap_agent/lib/appcontroller"
jdb_exe = "/home/vcap/app/.java-buildpack/hotswap_agent/lib/sc_jdb"

@logger.debug { "App ENV Vars:\n#{ENV.to_h.to_yaml}" }

devUtils =
{
:start => "default",
:server_port => ":$PORT",
:jdb_path => "#{jdb_exe}",
:jdb_debug_path => "jdb",
:app_url => "http://localhost:3000"
}

strDevUtils = devUtils.to_json.gsub! "\"", "\\\""
command.sub! "http.port=$PORT", "http.port=3000"
runCmd = (Base64.encode64("PORT=3000 " + command).delete("\n")).delete("\n")

startDev = "DEV_UTILS=\"#{strDevUtils}\" #{app_controller_exe} -startCmd #{runCmd}"
payload = {
'addons' => [],
'config_vars' => {},
'default_process_types' => { 'web' => startDev, 'task' => command }
}.to_yaml

@logger.debug { "Release Payload:\n#{payload}" }
payload
end

private_class_method :new

Expand Down