Reduce modifications to dashboard source
This allows two dashboard source archives to have the same MD5
digest if the dashboard has not been updated.
@@ -32,22 +32,25 @@ module AppDashboard
# Returns:
# A string specifying the location of the prepared archive.
def self.prep(public_ip, private_ip, persistent_storage, datastore_location)
- # Pass our public IP address (needed to connect to the AppController)
- # to the app.
+ # Write deployment-specific information that the dashboard needs.
lib_dir = File.join(APPSCALE_HOME, 'AppDashboard', 'lib')
- Djinn.log_run("echo \"MY_PUBLIC_IP = '#{public_ip}'\" > " \
- "#{lib_dir}/local_host.py")
- Djinn.log_run("echo \"UA_SERVER_IP = '#{private_ip}'\" >" \
- " #{lib_dir}/uaserver_host.py")
-
- File.open(File.join(lib_dir, 'datastore_location.py'), 'w') { |file|
- file.write("DATASTORE_LOCATION = '#{datastore_location}'")
+ lib_contents = {
+ 'local_host.py' => "MY_PUBLIC_IP = '#{public_ip}'",
+ 'uaserver_host.py' => "UA_SERVER_IP = '#{private_ip}'",
+ 'datastore_location.py' => "DATASTORE_LOCATION = '#{datastore_location}'"
+ }
+ lib_contents.each {|lib_file, contents|
+ lib_file = File.join(lib_dir, lib_file)
+ if File.read(lib_file) != contents
+ File.open(lib_file, 'w') { |file| file.write(contents) }
+ end
}
# TODO: tell the tools to disallow uploading apps called
# APP_NAME, and have start_appengine to do the same.
app_location = "#{persistent_storage}/apps/#{APP_NAME}.tar.gz"
- Djinn.log_run("tar -czf #{app_location} -C #{APPSCALE_HOME}/AppDashboard .")
+ Djinn.log_run(
+ "GZIP=-n tar -czf #{app_location} -C #{APPSCALE_HOME}/AppDashboard .")
# Tell the app what nginx port sits in front of it.
version_key = [APP_NAME, Djinn::DEFAULT_SERVICE,
@@ -55,12 +58,6 @@ module AppDashboard
port_file = "/etc/appscale/port-#{version_key}.txt"
HelperFunctions.write_file(port_file, LISTEN_PORT.to_s)
- # Restore repo template values.
- Djinn.log_run("echo \"MY_PUBLIC_IP = 'THIS VALUE WILL BE OVERWRITTEN" \
- " ON STARTUP'\" > #{APPSCALE_HOME}/AppDashboard/lib/local_host.py")
- Djinn.log_run("echo \"UA_SERVER_IP = 'THIS VALUE WILL BE OVERWRITTEN" \
- " ON STARTUP'\" > #{APPSCALE_HOME}/AppDashboard/lib/uaserver_host.py")
-
Djinn.log_debug('Done setting dashboard.')
app_location
