Compare commits
No commits in common. "main" and "v0.1.1" have entirely different histories.
27
Gemfile.lock
27
Gemfile.lock
@ -4,10 +4,10 @@ GEM
|
|||||||
anyflake (0.0.1)
|
anyflake (0.0.1)
|
||||||
ast (2.4.3)
|
ast (2.4.3)
|
||||||
base64 (0.2.0)
|
base64 (0.2.0)
|
||||||
bigdecimal (3.1.9)
|
bigdecimal (3.1.8)
|
||||||
csv (3.3.3)
|
csv (3.3.0)
|
||||||
diff-lcs (1.6.1)
|
diff-lcs (1.6.0)
|
||||||
httparty (0.23.1)
|
httparty (0.22.0)
|
||||||
csv
|
csv
|
||||||
mini_mime (>= 1.0.0)
|
mini_mime (>= 1.0.0)
|
||||||
multi_xml (>= 0.5.2)
|
multi_xml (>= 0.5.2)
|
||||||
@ -17,9 +17,9 @@ GEM
|
|||||||
ksuid (1.0.0)
|
ksuid (1.0.0)
|
||||||
language_server-protocol (3.17.0.4)
|
language_server-protocol (3.17.0.4)
|
||||||
lint_roller (1.1.0)
|
lint_roller (1.1.0)
|
||||||
logger (1.7.0)
|
logger (1.6.6)
|
||||||
mini_mime (1.1.5)
|
mini_mime (1.1.5)
|
||||||
minitest (5.25.5)
|
minitest (5.25.4)
|
||||||
multi_json (1.15.0)
|
multi_json (1.15.0)
|
||||||
multi_xml (0.7.1)
|
multi_xml (0.7.1)
|
||||||
bigdecimal (~> 3.1)
|
bigdecimal (~> 3.1)
|
||||||
@ -28,14 +28,14 @@ GEM
|
|||||||
nanoid (2.0.0)
|
nanoid (2.0.0)
|
||||||
nio4r (2.7.4)
|
nio4r (2.7.4)
|
||||||
parallel (1.26.3)
|
parallel (1.26.3)
|
||||||
parser (3.3.7.4)
|
parser (3.3.7.2)
|
||||||
ast (~> 2.4.1)
|
ast (~> 2.4.1)
|
||||||
racc
|
racc
|
||||||
prism (1.4.0)
|
prism (1.3.0)
|
||||||
puma (6.6.0)
|
puma (6.6.0)
|
||||||
nio4r (~> 2.0)
|
nio4r (~> 2.0)
|
||||||
racc (1.8.1)
|
racc (1.8.1)
|
||||||
rack (3.1.12)
|
rack (3.1.11)
|
||||||
rack-protection (4.1.1)
|
rack-protection (4.1.1)
|
||||||
base64 (>= 0.1.0)
|
base64 (>= 0.1.0)
|
||||||
logger (>= 1.6.0)
|
logger (>= 1.6.0)
|
||||||
@ -49,7 +49,7 @@ GEM
|
|||||||
rack (>= 3)
|
rack (>= 3)
|
||||||
rainbow (3.1.1)
|
rainbow (3.1.1)
|
||||||
rake (13.2.1)
|
rake (13.2.1)
|
||||||
rbs (3.9.2)
|
rbs (3.8.1)
|
||||||
logger
|
logger
|
||||||
regexp_parser (2.10.0)
|
regexp_parser (2.10.0)
|
||||||
rspec (3.13.0)
|
rspec (3.13.0)
|
||||||
@ -76,14 +76,13 @@ GEM
|
|||||||
rubocop-ast (>= 1.38.0, < 2.0)
|
rubocop-ast (>= 1.38.0, < 2.0)
|
||||||
ruby-progressbar (~> 1.7)
|
ruby-progressbar (~> 1.7)
|
||||||
unicode-display_width (>= 2.4.0, < 4.0)
|
unicode-display_width (>= 2.4.0, < 4.0)
|
||||||
rubocop-ast (1.43.0)
|
rubocop-ast (1.41.0)
|
||||||
parser (>= 3.3.7.2)
|
parser (>= 3.3.7.2)
|
||||||
prism (~> 1.4)
|
|
||||||
rubocop-performance (1.24.0)
|
rubocop-performance (1.24.0)
|
||||||
lint_roller (~> 1.1)
|
lint_roller (~> 1.1)
|
||||||
rubocop (>= 1.72.1, < 2.0)
|
rubocop (>= 1.72.1, < 2.0)
|
||||||
rubocop-ast (>= 1.38.0, < 2.0)
|
rubocop-ast (>= 1.38.0, < 2.0)
|
||||||
ruby-lsp (0.23.13)
|
ruby-lsp (0.23.11)
|
||||||
language_server-protocol (~> 3.17.0)
|
language_server-protocol (~> 3.17.0)
|
||||||
prism (>= 1.2, < 2.0)
|
prism (>= 1.2, < 2.0)
|
||||||
rbs (>= 3, < 4)
|
rbs (>= 3, < 4)
|
||||||
@ -103,7 +102,7 @@ GEM
|
|||||||
rack-protection (= 4.1.1)
|
rack-protection (= 4.1.1)
|
||||||
sinatra (= 4.1.1)
|
sinatra (= 4.1.1)
|
||||||
tilt (~> 2.0)
|
tilt (~> 2.0)
|
||||||
sorbet-runtime (0.5.11971)
|
sorbet-runtime (0.5.11911)
|
||||||
standard (1.47.0)
|
standard (1.47.0)
|
||||||
language_server-protocol (~> 3.17.0.2)
|
language_server-protocol (~> 3.17.0.2)
|
||||||
lint_roller (~> 1.0)
|
lint_roller (~> 1.0)
|
||||||
|
68
app.rb
68
app.rb
@ -2,7 +2,6 @@ require "bundler/setup"
|
|||||||
require "sinatra"
|
require "sinatra"
|
||||||
require "sinatra/cookies"
|
require "sinatra/cookies"
|
||||||
require "sinatra/multi_route"
|
require "sinatra/multi_route"
|
||||||
require "sinatra/quiet_logger"
|
|
||||||
require "time"
|
require "time"
|
||||||
require "fileutils"
|
require "fileutils"
|
||||||
require "json"
|
require "json"
|
||||||
@ -21,7 +20,7 @@ $LOAD_PATH.unshift File.dirname(__FILE__) + "/lib"
|
|||||||
|
|
||||||
require "config"
|
require "config"
|
||||||
|
|
||||||
VERSION = "0.1.4"
|
VERSION = "0.1.1"
|
||||||
|
|
||||||
CHUNK_SIZE = 1024**2
|
CHUNK_SIZE = 1024**2
|
||||||
SESSION_SECRET_HEX_LENGTH = 64
|
SESSION_SECRET_HEX_LENGTH = 64
|
||||||
@ -53,12 +52,9 @@ DURATION_PARTS = [
|
|||||||
|
|
||||||
config = Config.new
|
config = Config.new
|
||||||
|
|
||||||
set :quiet_logger_prefixes, %w[livez readyz]
|
|
||||||
set :session_secret, config.session_secret.unwrap
|
set :session_secret, config.session_secret.unwrap
|
||||||
set :public_folder, __dir__ + "/static"
|
set :public_folder, __dir__ + "/static"
|
||||||
|
|
||||||
register Sinatra::QuietLogger
|
|
||||||
|
|
||||||
module Sinatra
|
module Sinatra
|
||||||
module RequestHeadersHelper
|
module RequestHeadersHelper
|
||||||
def req_headers
|
def req_headers
|
||||||
@ -117,6 +113,7 @@ class TickTock
|
|||||||
def initialize
|
def initialize
|
||||||
@pid = ppid
|
@pid = ppid
|
||||||
@procfs_f = format "/proc/%s/stat", @pid
|
@procfs_f = format "/proc/%s/stat", @pid
|
||||||
|
puts @pid
|
||||||
end
|
end
|
||||||
|
|
||||||
def uptime
|
def uptime
|
||||||
@ -167,7 +164,7 @@ class Sleep
|
|||||||
include State
|
include State
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@file = "/dev/shm/sleepy"
|
@file = "/dev/shm/sleep"
|
||||||
end
|
end
|
||||||
|
|
||||||
def asleep?
|
def asleep?
|
||||||
@ -184,11 +181,20 @@ class Sleep
|
|||||||
end
|
end
|
||||||
|
|
||||||
def ppid
|
def ppid
|
||||||
pid = ENV.fetch "PUMA_PID", Process.pid
|
pid = Process.pid
|
||||||
begin
|
# self
|
||||||
Integer pid
|
ps = File.open "/proc/#{pid}/stat", &:readline
|
||||||
rescue ArgumentError
|
ps = ps.split(" ")
|
||||||
-1
|
ppid = Integer(ps[3])
|
||||||
|
|
||||||
|
# ppid
|
||||||
|
ps = File.open "/proc/#{ppid}/stat", &:readline
|
||||||
|
ps = ps.split(" ")
|
||||||
|
|
||||||
|
if ps[1].include? "ruby"
|
||||||
|
ppid
|
||||||
|
else
|
||||||
|
pid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -226,7 +232,9 @@ end
|
|||||||
|
|
||||||
enable :sessions
|
enable :sessions
|
||||||
|
|
||||||
puts "#{NAME} #{VERSION} staring, per aspera ad astra"
|
on_start do
|
||||||
|
puts "#{NAME} #{VERSION} staring, per aspera ad astra"
|
||||||
|
end
|
||||||
|
|
||||||
configure do
|
configure do
|
||||||
mime_type :json, "application/json"
|
mime_type :json, "application/json"
|
||||||
@ -301,23 +309,6 @@ get "/headers", provides: "json" do
|
|||||||
jsonify h, pretty:
|
jsonify h, pretty:
|
||||||
end
|
end
|
||||||
|
|
||||||
get "/uptime", provides: "json" do
|
|
||||||
tt = TickTock.new
|
|
||||||
x = {started_at: tt.started_at, seconds: tt.uptime.to_i, human: human_time(tt.uptime.to_i)}
|
|
||||||
|
|
||||||
jsonify x
|
|
||||||
end
|
|
||||||
|
|
||||||
post "/api/livez/toggle" do
|
|
||||||
Health.instance.toggle
|
|
||||||
"ok\n"
|
|
||||||
end
|
|
||||||
|
|
||||||
post "/api/livez/sleep" do
|
|
||||||
Sleep.instance.toggle
|
|
||||||
"ok\n"
|
|
||||||
end
|
|
||||||
|
|
||||||
get "/livez" do
|
get "/livez" do
|
||||||
error 503 unless Health.instance.healthy?
|
error 503 unless Health.instance.healthy?
|
||||||
|
|
||||||
@ -326,6 +317,23 @@ get "/livez" do
|
|||||||
Health.instance.to_s
|
Health.instance.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get "/livez/uptime" do
|
||||||
|
tt = TickTock.new
|
||||||
|
x = {started_at: tt.started_at, seconds: tt.uptime.to_i, human: human_time(tt.uptime.to_i)}
|
||||||
|
|
||||||
|
jsonify x
|
||||||
|
end
|
||||||
|
|
||||||
|
post "/livez/toggle" do
|
||||||
|
Health.instance.toggle
|
||||||
|
"ok\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
post "/livez/sleep" do
|
||||||
|
Sleep.instance.toggle
|
||||||
|
"ok\n"
|
||||||
|
end
|
||||||
|
|
||||||
get "/readyz" do
|
get "/readyz" do
|
||||||
error 503 unless Ready.instance.ready?
|
error 503 unless Ready.instance.ready?
|
||||||
|
|
||||||
@ -374,7 +382,7 @@ post "/halt" do
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
get "/pid", provides: "json" do
|
get "/pid" do
|
||||||
pretty = params.key? :pretty
|
pretty = params.key? :pretty
|
||||||
|
|
||||||
jsonify({ppid: ppid, pid: Process.pid}, pretty:)
|
jsonify({ppid: ppid, pid: Process.pid}, pretty:)
|
||||||
|
@ -15,10 +15,10 @@ type: application
|
|||||||
# This is the chart version. This version number should be incremented each time you make changes
|
# This is the chart version. This version number should be incremented each time you make changes
|
||||||
# to the chart and its templates, including the app version.
|
# to the chart and its templates, including the app version.
|
||||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||||
version: 0.1.4
|
version: 0.1.1
|
||||||
|
|
||||||
# This is the version number of the application being deployed. This version number should be
|
# This is the version number of the application being deployed. This version number should be
|
||||||
# incremented each time you make changes to the application. Versions are not expected to
|
# incremented each time you make changes to the application. Versions are not expected to
|
||||||
# follow Semantic Versioning. They should reflect the version the application is using.
|
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||||
# It is recommended to use it with quotes.
|
# It is recommended to use it with quotes.
|
||||||
appVersion: "0.1.4"
|
appVersion: "0.1.1"
|
||||||
|
@ -97,7 +97,7 @@ readinessProbe:
|
|||||||
|
|
||||||
# This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/
|
# This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/
|
||||||
autoscaling:
|
autoscaling:
|
||||||
enabled: true
|
enabled: false
|
||||||
minReplicas: 2
|
minReplicas: 2
|
||||||
maxReplicas: 100
|
maxReplicas: 100
|
||||||
targetCPUUtilizationPercentage: 80
|
targetCPUUtilizationPercentage: 80
|
||||||
|
@ -1 +0,0 @@
|
|||||||
ENV["PUMA_PID"] = Process.pid.to_s
|
|
@ -16,7 +16,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: kubernaut
|
- name: kubernaut
|
||||||
image: git.kill0.net/ryanc/kubernaut:0.1.4
|
image: git.kill0.net/ryanc/kubernaut:0.1.1
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- name: sinatra-web
|
- name: sinatra-web
|
||||||
|
Loading…
x
Reference in New Issue
Block a user