Skip to content

Commit

Permalink
Merge pull request #5 from customink/bc/remedy-hostname-no-such-file-…
Browse files Browse the repository at this point in the history
…and-force-string

[Bugfix] Remedy hostname "No such file" error, enforce string type
  • Loading branch information
brcarp authored Feb 15, 2022
2 parents 58cd33f + bcd7533 commit 349de7a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [1.3.1] - 2022-02-25

### Fixed

- There is no `hostname` on Lambda. Use return status of `which hostname` before calling `hostname`.
- Enforce string type on `hostname=` method using `to_s`
- Change length-check on `@hostname` to use Ruby `empty?` predicate method

## [1.3.0] - 2020-02-04

### Added
Expand Down
6 changes: 3 additions & 3 deletions lib/is_it_working/handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Handler
def initialize(app=nil, route_path="/is_it_working", &block)
@app = app
@route_path = route_path
@hostname = `hostname`.to_s.chomp
@hostname = %x(which hostname >/dev/null && hostname).chomp
@timers = []
@filters = []
@reporters = []
Expand All @@ -57,7 +57,7 @@ def call(env)
# the system hostname. You should override it if the value reported as the hostname by
# the system is not useful or if exposing it publicly would create a security risk.
def hostname=(val)
@hostname = val
@hostname = val.to_s
end

# Add a status check to the handler.
Expand Down Expand Up @@ -159,7 +159,7 @@ def render(statuses, elapsed_time) #:nodoc:
end

info = []
info << "Host: #{@hostname}" unless @hostname.size == 0
info << "Host: #{@hostname}" unless @hostname.empty?
info << "PID: #{$$}"
info << "Timestamp: #{Time.now.iso8601}"
info << "Elapsed Time: #{(elapsed_time * 1000).round}ms"
Expand Down
2 changes: 1 addition & 1 deletion lib/is_it_working/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module IsItWorking
VERSION = '1.3.0'.freeze
VERSION = '1.3.1'.freeze
end

0 comments on commit 349de7a

Please sign in to comment.