Build APIServer at runtime when there are changes
@@ -3669,6 +3669,33 @@ class Djinn
Djinn.log_info('Finished building Hermes.')
end
+ def build_api_server
+ Djinn.log_info('Building uncommitted APIServer changes')
+ src = File.join(APPSCALE_HOME, 'APIServer')
+ proto_dest = File.join(src, 'appscale', 'api_server')
+ unless system("protoc --proto_path=#{src} --python_out=#{proto_dest} " \
+ "#{src}/*.proto")
+ Djinn.log_error('Unable to compile APIServer proto files')
+ return
+ end
+
+ api_server_venv = File.join('/', 'opt', 'appscale_api_server')
+ upgrade_package = "source #{api_server_venv}/bin/activate && " \
+ "pip install --upgrade --no-deps #{src} > /dev/null 2>&1"
+ unless system("bash -c '#{upgrade_package}'")
+ Djinn.log_error('Unable to build APIServer (install failed).')
+ return
+ end
+ upgrade_deps = "source #{api_server_venv}/bin/activate && " \
+ "pip install #{src} > /dev/null 2>&1"
+ unless system("bash -c '#{upgrade_deps}'")
+ Djinn.log_error(
+ 'Unable to build APIServer (install dependencies failed).')
+ return
+ end
+ Djinn.log_info('Finished building APIServer.')
+ end
+
# Run a build on modified directories so that changes will take effect.
def build_uncommitted_changes
status = `git -C #{APPSCALE_HOME} status`
@@ -3678,6 +3705,7 @@ class Djinn
build_common if status.include?('common')
build_java_appserver if status.include?('AppServer_Java')
build_hermes if status.include?('Hermes')
+ build_api_server if status.include?('APIServer')
end
def configure_ejabberd_cert
@@ -3809,13 +3837,23 @@ class Djinn
ip = dest_node.private_ip
options = "-e 'ssh -i #{ssh_key}' -a --filter '- *.pyc'"
- ["#{APPSCALE_HOME}/AdminServer", "#{APPSCALE_HOME}/AppDB",
- "#{APPSCALE_HOME}/AppManager", "#{APPSCALE_HOME}/AppTaskQueue",
- "#{APPSCALE_HOME}/AppController", "#{APPSCALE_HOME}/common",
- "#{APPSCALE_HOME}/InfrastructureManager", "#{APPSCALE_HOME}/AppDashboard",
- "#{APPSCALE_HOME}/scripts", "#{APPSCALE_HOME}/AppServer",
- "#{APPSCALE_HOME}/AppServer_Java", "#{APPSCALE_HOME}/XMPPReceiver",
- "#{APPSCALE_HOME}/LogService"].each { |dir|
+ to_copy = %w(
+ AdminServer
+ APIServer
+ AppController
+ AppDashboard
+ AppDB
+ AppManager
+ AppServer
+ AppServer_Java
+ AppTaskQueue
+ common
+ InfrastructureManager
+ LogService
+ scripts
+ XMPPReceiver
+ ).map { |path| File.join(APPSCALE_HOME, path) }
+ to_copy.each { |dir|
if system("rsync #{options} #{dir}/* root@#{ip}:#{dir}") != true
Djinn.log_warn("Rsync of #{dir} to #{ip} failed!")
end
