50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/vae_local.rb', line 50
def run
options = { port: 9999, server: ProxyServer, log_level: "warning" }
loop {
break if VaeLocal.port_open?(options[:port])
options[:port] = options[:port] - 1
}
ARGV.options do |opts|
opts.banner = BANNER + "\n\nUsage: vae [options]\n starts a local development server\n vae [options] deploy\n deploys the source in Git repository or provided URL to the Vae servers\n\n If you are using the Vae Production environment features:\n vae [options] stage\n deploys the source in Git repository or provided URL to the staging environment\n vae [options] stagerelease\n deploys the source in Git repository or provided URL to the staging environment\n and releases it to the production environment\n vae [options] release\n releases the current staging environment to the production environment\n vae [options] rollback\n rolls back the production environment to a previous release\n\nAvailable Options:"
opts.on("-u","--username <username>","Your Vae username") { |o| options[:username] = o }
opts.on("-P","--password <password>","Your Vae password") { |o| options[:password] = o }
opts.on("-p","--port <port number>","Start server on this port") { |o| options[:port] = o.to_i; raise VaeError, "Port #{o.to_i} is already in use." unless VaeLocal.port_open?(o.to_i) }
opts.on("-r","--root <path to site root>","Path to the root of the local copy of your Vae site.") { |o| options[:site_root] = o }
opts.on("-s","--site <subdomain>","Vae subdomain for this site") { |o| options[:site] = o }
opts.on("-f","--full-stack [php|hhvm]","Run in Full Stack Mode. Optionally provide 'php' or 'hhvm' to specify your preferred PHP runtime") { |o| options[:server] = FullStack; options[:php_runtime] = o }
opts.on("-t","--print-node","Run in Print Node Mode. This will register this node as a print node with Vae.") { |o| options[:server] = PrintNodeServer }
opts.on("-U","--url <url>","If running stage or stagerelease, provide the URL of a ZIP file to deploy here") { |o| options[:branch] = o }
opts.on("-b","--branch <branch>","If running stage or stagerelease, override the Git branch to deploy here") { |o| options[:branch] = o }
opts.on("-B","--built_path <path>","If running stage or stagerelease, and you want to provide the built files to deploy from a local path, provide that path here") { |o| options[:built_path] = o }
opts.on("-d","--data-path <path>","Where to Store Content and Image Data When In Full Stack Mode") { |o| options[:data_path] = o }
opts.on("-l","--log-level <level>","Vaedb Log Level (for Full Stack Mode)") { |o| options[:log_level] = o }
opts.on_tail("-h","--help", "Show this help message") { puts opts; exit }
opts.parse!
end
options[:site_root] = Dir.pwd if options[:site_root].nil? and (File.exists?("#{Dir.pwd}/__vae.yml") or File.exists?("#{Dir.pwd}/__verb.yml"))
if options[:site_root]
[ "verb", "vae" ].each do |name|
if File.exists?("#{options[:site_root]}/__#{name}.yml")
site_conf_file = File.read("#{options[:site_root]}/__#{name}.yml")
site_conf = YAML.load(site_conf_file)
options[:site] ||= site_conf[name]["site"] if site_conf[name] and site_conf[name]["site"]
end
end
end
raise VaeError, "We could not determine the Vae subdomain for this site. Please specify it manually by using the --site option or create a __vae.yml file within the site root." if options[:site].nil?
keys = VaeLocal.read_auth_keys
if key = keys['site_keys'][options[:site]] and options[:password].nil?
options[:auth_key] = key
end
unless options[:auth_key]
raise VaeError, "We could not determine the Vae username that you use. Please specify it manually by using the --username option." if options[:username].nil?
if options[:password].nil?
options[:password] = ask("Please enter the Vae password for username #{options[:username]}:") { |q| q.echo = false }
end
end
if [ "deploy", "release", "rollback", "stage", "stagerelease" ].include?(ARGV.last)
stageaction = true
elsif options[:server] == PrintNodeServer
else
raise VaeError, "You did not specify the path to the root of the local copy of your Vae site. Please specify it manually by using the --root option or cd to the site root (and make sure it contains a __vae.yml file)." unless options[:site_root]
raise VaeError, "You specified an invalid path to the local copy of your Vae site." unless File.exists?(options[:site_root])
end
site = Site.new(subdomain: options[:site], root: options[:site_root], username: options[:username], password: options[:password], auth_key: options[:auth_key])
if stageaction
site.login_to_server
stagerelease(ARGV.last, options[:site], site.auth_key, options[:branch], options[:built_path])
exit
end
Dir.chdir File.dirname(__FILE__)
puts BANNER
options[:server].new(site, options).run
puts "Thanks for using Vae!"
end
|