feat: add support for port detection
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
b588503b79
commit
a007211e29
1 changed files with 7 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
require "path"
|
require "path"
|
||||||
require "file_utils"
|
require "file_utils"
|
||||||
|
require "socket"
|
||||||
|
|
||||||
require "./module"
|
require "./module"
|
||||||
require "./config"
|
require "./config"
|
||||||
|
@ -38,7 +39,12 @@ module DocMachine::Build
|
||||||
end
|
end
|
||||||
|
|
||||||
private def _port_available?(port)
|
private def _port_available?(port)
|
||||||
true
|
sock = Socket.new(Socket::Family::INET, Socket::Type::STREAM)
|
||||||
|
sock.bind(Socket::IPAddress.new("0.0.0.0", port))
|
||||||
|
sock.close
|
||||||
|
return true
|
||||||
|
rescue ex : Socket::BindError
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
private def _avoid_duplicates
|
private def _avoid_duplicates
|
||||||
|
|
Loading…
Reference in a new issue