vae 0.8.10 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/bin/vae +2 -0
- data/lib/full_stack.rb +1 -0
- data/lib/print_node_server.rb +94 -0
- data/lib/proxy_server.rb +3 -2
- data/lib/site.rb +6 -3
- data/lib/vae_local.rb +4 -2
- data/lib/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: de2f275762e0dc9d57e999436934d851ebde0f017d5b04fe9ce2a5fb2c7ce121
|
4
|
+
data.tar.gz: 49ad8260ca9356c246de744522007a0ead78e16565859365e7687da0e11eab86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0461a07291b53db820ed2be157c7674a0e5ed853c45e9d2bc38f1f6a15bc3aeb310ecb308481287f9328a596c858e13d8262eee03112009a11b947bf23cfcd8e
|
7
|
+
data.tar.gz: 6c26b227a0027ead0983d53767eda9cd9ac8637814e37b27fc82755a51e5e1c882a9dc133be64c3721756571438403676f1fdbcaa65bbadac1158c8870d2a6b2
|
data/bin/vae
CHANGED
@@ -18,6 +18,7 @@ require 'optparse'
|
|
18
18
|
require 'ptools'
|
19
19
|
require 'rest-client'
|
20
20
|
require 'shellwords'
|
21
|
+
require 'tempfile'
|
21
22
|
require 'thread'
|
22
23
|
require 'webrick'
|
23
24
|
require 'yaml'
|
@@ -30,6 +31,7 @@ require 'haml'
|
|
30
31
|
require 'full_stack'
|
31
32
|
require 'logging'
|
32
33
|
require 'proxy_server'
|
34
|
+
require 'print_node_server'
|
33
35
|
require 'servlet'
|
34
36
|
require 'site'
|
35
37
|
require 'vae_error'
|
data/lib/full_stack.rb
CHANGED
@@ -0,0 +1,94 @@
|
|
1
|
+
class PrintNodeServer < ProxyServer
|
2
|
+
CHROME_PATH = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
|
3
|
+
POLL_EVERY = 10 # seconds
|
4
|
+
|
5
|
+
def run
|
6
|
+
check_for_requirements
|
7
|
+
register_node
|
8
|
+
|
9
|
+
puts "Vae Print Node active, waiting for print jobs ..."
|
10
|
+
puts " (hit Control+C to exit)"
|
11
|
+
|
12
|
+
trap("INT") { @stop = true }
|
13
|
+
main_loop
|
14
|
+
|
15
|
+
puts "Quit signal received, cleaning up ..."
|
16
|
+
end
|
17
|
+
|
18
|
+
def check_for_requirements
|
19
|
+
raise "Could not find Google Chrome. Please make sure Google Chrome is installed." if !File.exists?(CHROME_PATH)
|
20
|
+
raise "Could not find chromehtml2pdf. Run:\nnpm install -g chromehtml2pdf" if !File.which("chromehtml2pdf")
|
21
|
+
end
|
22
|
+
|
23
|
+
def register_node
|
24
|
+
res = send_post
|
25
|
+
if match = res.body.match(/<secret-key>([a-f0-9]*)<\/secret-key>/)
|
26
|
+
@node_id = "/#{match[1]}"
|
27
|
+
else
|
28
|
+
raise "Could not connect to Vae to register print node."
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def send_post
|
33
|
+
@last_post_at = Time.now
|
34
|
+
options = {
|
35
|
+
method: :post,
|
36
|
+
headers: { "Content-type": "application/json" },
|
37
|
+
url: "#{@site.vaeplatform_url}/api/local/v1/print_nodes#{@node_id}",
|
38
|
+
payload: {
|
39
|
+
print_node: {
|
40
|
+
name: node_name,
|
41
|
+
default_printer: default_printer,
|
42
|
+
printers_list: printers_list,
|
43
|
+
print_queue_status: print_queue_status
|
44
|
+
}
|
45
|
+
}.to_json
|
46
|
+
}
|
47
|
+
options[:verify_ssl] = false if ENV['VAEPLATFORM_LOCAL']
|
48
|
+
res = RestClient::Request.execute(options)
|
49
|
+
@last_successful_post_at = Time.now
|
50
|
+
res
|
51
|
+
end
|
52
|
+
|
53
|
+
def main_loop
|
54
|
+
loop do
|
55
|
+
break if @stop or (@last_successful_post_at + 3600) < Time.now
|
56
|
+
loop_action if (@last_post_at + POLL_EVERY) < Time.now
|
57
|
+
sleep 1
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def loop_action
|
62
|
+
res = send_post
|
63
|
+
if match = res.body.match(/<next-job>([^<]*)<\/next-job>/)
|
64
|
+
url = match[1]
|
65
|
+
path = "/tmp/VaePrintNode-#{rand.to_s.gsub(".", "")}.pdf"
|
66
|
+
puts "Printing #{url} to #{path}"
|
67
|
+
`chromehtml2pdf --marginLeft 0.5 --marginRight 0.5 --out "#{path}" #{Shellwords.shellescape(url)}`
|
68
|
+
if File.exists?(path)
|
69
|
+
`lp #{path}`
|
70
|
+
Thread.new { sleep 15; FileUtils.rm(path) }
|
71
|
+
else
|
72
|
+
puts "Error: could not generate PDF!"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
rescue StandardError => e
|
76
|
+
puts e.message
|
77
|
+
end
|
78
|
+
|
79
|
+
def node_name
|
80
|
+
Socket.gethostname
|
81
|
+
end
|
82
|
+
|
83
|
+
def default_printer
|
84
|
+
""
|
85
|
+
end
|
86
|
+
|
87
|
+
def printers_list
|
88
|
+
`lpstat -p`
|
89
|
+
end
|
90
|
+
|
91
|
+
def print_queue_status
|
92
|
+
`lpq`
|
93
|
+
end
|
94
|
+
end
|
data/lib/proxy_server.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
class ProxyServer
|
2
2
|
def initialize(site, options)
|
3
|
-
|
3
|
+
@site = site
|
4
4
|
@options = options
|
5
5
|
|
6
6
|
set_mime_types
|
7
7
|
end
|
8
8
|
|
9
9
|
def run
|
10
|
+
site.login_to_server
|
10
11
|
server = Mongrel::Configurator.new host: "0.0.0.0", port: @options[:port] do
|
11
12
|
listener do
|
12
|
-
uri "/", handler: VaeSiteServlet.new(
|
13
|
+
uri "/", handler: VaeSiteServlet.new(@site)
|
13
14
|
end
|
14
15
|
trap("INT") { raise Mongrel::StopServer }
|
15
16
|
run
|
data/lib/site.rb
CHANGED
@@ -10,7 +10,6 @@ class Site
|
|
10
10
|
@auth_key = options[:auth_key] if options[:auth_key]
|
11
11
|
@session_id = Digest::MD5.hexdigest(rand.to_s)
|
12
12
|
@data_path = options[:data_path] || "#{@root}/.vae/data/"
|
13
|
-
@data = login_to_server
|
14
13
|
end
|
15
14
|
|
16
15
|
def domain
|
@@ -19,7 +18,6 @@ class Site
|
|
19
18
|
|
20
19
|
def fetch_from_server(req)
|
21
20
|
http = Net::HTTP.new(domain, 443)
|
22
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
23
21
|
http.use_ssl = true
|
24
22
|
http.start { |http|
|
25
23
|
http.read_timeout = 120
|
@@ -50,7 +48,7 @@ class Site
|
|
50
48
|
VaeLocal.write_auth_key(subdomain, data['auth_key'])
|
51
49
|
@auth_key = data['auth_key']
|
52
50
|
end
|
53
|
-
data
|
51
|
+
@data = data
|
54
52
|
rescue JSON::ParserError
|
55
53
|
raise VaeError, "An unknown error occurred signing into Vae Platform. Please email support for help."
|
56
54
|
end
|
@@ -58,4 +56,9 @@ class Site
|
|
58
56
|
def subdomain_base
|
59
57
|
subdomain.split(".").first
|
60
58
|
end
|
59
|
+
|
60
|
+
def vaeplatform_url
|
61
|
+
VaeLocal.vaeplatform_url(subdomain)
|
62
|
+
end
|
61
63
|
end
|
64
|
+
|
data/lib/vae_local.rb
CHANGED
@@ -5,7 +5,7 @@ class VaeLocal
|
|
5
5
|
local = ENV['VAEPLATFORM_LOCAL']
|
6
6
|
http = Net::HTTP.new(vaeplatform_host(subdomain), (local ? 80 : 443))
|
7
7
|
http.use_ssl = true unless local
|
8
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
8
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if local
|
9
9
|
http.start { |http|
|
10
10
|
http.read_timeout = 120
|
11
11
|
http.request(req)
|
@@ -21,7 +21,7 @@ class VaeLocal
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.vaeplatform_url(subdomain)
|
24
|
-
"
|
24
|
+
"https://#{vaeplatform_host(subdomain)}"
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.read_auth_keys
|
@@ -62,6 +62,7 @@ class VaeLocal
|
|
62
62
|
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 }
|
63
63
|
opts.on("-s","--site <subdomain>","Vae subdomain for this site") { |o| options[:site] = o }
|
64
64
|
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 }
|
65
|
+
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 }
|
65
66
|
opts.on("-U","--url <url>","If running stage or stagerelease, provide the URL of a ZIP file to deploy here") { |o| options[:branch] = o }
|
66
67
|
opts.on("-b","--branch <branch>","If running stage or stagerelease, override the Git branch to deploy here") { |o| options[:branch] = o }
|
67
68
|
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 }
|
@@ -98,6 +99,7 @@ class VaeLocal
|
|
98
99
|
|
99
100
|
if [ "deploy", "release", "rollback", "stage", "stagerelease" ].include?(ARGV.last)
|
100
101
|
stageaction = true
|
102
|
+
elsif options[:server] == PrintNodeServer
|
101
103
|
else
|
102
104
|
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]
|
103
105
|
raise VaeError, "You specified an invalid path to the local copy of your Vae site." unless File.exists?(options[:site_root])
|
data/lib/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
VER = "0.
|
1
|
+
VER = "0.9.0"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vae
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Action Verb, LLC
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-03-
|
12
|
+
date: 2019-03-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chunky_png
|
@@ -189,6 +189,7 @@ files:
|
|
189
189
|
- bin/vae
|
190
190
|
- lib/full_stack.rb
|
191
191
|
- lib/logging.rb
|
192
|
+
- lib/print_node_server.rb
|
192
193
|
- lib/proxy_server.rb
|
193
194
|
- lib/servlet.rb
|
194
195
|
- lib/site.rb
|
@@ -217,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
218
|
version: '0'
|
218
219
|
requirements: []
|
219
220
|
rubyforge_project:
|
220
|
-
rubygems_version: 2.
|
221
|
+
rubygems_version: 2.7.6
|
221
222
|
signing_key:
|
222
223
|
specification_version: 4
|
223
224
|
summary: This gem allows for local development for sites on Vae Platform (http://vaeplatform.com/)
|