This repository was archived by the owner on May 14, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +48
-3
lines changed
lib/poise_application_ruby/resources Expand file tree Collapse file tree 3 files changed +48
-3
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,10 @@ class Resource < Chef::Resource
5050 # @!attribute port
5151 # Port to bind to.
5252 attribute ( :port , kind_of : [ String , Integer ] , default : 80 )
53+
54+ # @!attribute socket
55+ # Listen on a unix socket instead of a port
56+ attribute ( :socket , kind_of : [ TrueClass , FalseClass ] , default : false )
5357 end
5458
5559 # Provider for `application_puma`.
@@ -75,10 +79,21 @@ def configru_path
7579 end
7680 end
7781
82+ # Path to the socket file.
83+ #
84+ # @return [String]
85+ def socket_path
86+ @socket_path ||= "unix:///var/run/#{ ::File . basename ( new_resource . path ) } .sock"
87+ end
88+
7889 # Set service resource options.
7990 def service_options ( resource )
8091 super
81- resource . ruby_command ( "puma --port #{ new_resource . port } #{ configru_path } " )
92+ unless new_resource . socket
93+ resource . ruby_command ( "puma --port #{ new_resource . port } #{ configru_path } " )
94+ else
95+ resource . ruby_command ( "puma -b #{ socket_path } #{ configru_path } " )
96+ end
8297 end
8398 end
8499 end
Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ class Resource < Chef::Resource
3131
3232 attribute ( :port , kind_of : [ String , Integer ] , default : 80 )
3333 attribute ( :config_path , kind_of : String )
34+
35+ # @!attribute socket
36+ # Listen on a unix socket instead of a port
37+ attribute ( :socket , kind_of : [ TrueClass , FalseClass ] , default : false )
3438 end
3539
3640 class Provider < Chef ::Provider
@@ -51,10 +55,21 @@ def configru_path
5155 end
5256 end
5357
58+ # Path to the socket file.
59+ #
60+ # @return [String]
61+ def socket_path
62+ @socket_path ||= "unix:///var/run/#{ ::File . basename ( new_resource . path ) } .sock"
63+ end
64+
5465 # (see PoiseApplication::ServiceMixin#service_options)
5566 def service_options ( resource )
5667 super
57- cmd = "thin --rackup #{ configru_path } --port #{ new_resource . port } "
68+ unless new_resource . socket
69+ cmd = "thin --rackup #{ configru_path } --port #{ new_resource . port } "
70+ else
71+ cmd = "thin --rackup #{ configru_path } --socket #{ socket_path } "
72+ end
5873 cmd << " --config #{ ::File . expand_path ( new_resource . config_path , new_resource . path ) } " if new_resource . config_path
5974 resource . ruby_command ( cmd )
6075 end
Original file line number Diff line number Diff line change @@ -51,6 +51,10 @@ class Resource < Chef::Resource
5151 # @!attribute port
5252 # Port to bind to.
5353 attribute ( :port , kind_of : [ String , Integer ] , default : 80 )
54+
55+ # @!attribute socket
56+ # Listen on a unix socket instead of a port
57+ attribute ( :socket , kind_of : [ TrueClass , FalseClass ] , default : false )
5458 end
5559
5660 # Provider for `application_unicorn`.
@@ -76,10 +80,21 @@ def configru_path
7680 end
7781 end
7882
83+ # Path to the socket file.
84+ #
85+ # @return [String]
86+ def socket_path
87+ @socket_path ||= "unix:///var/run/#{ ::File . basename ( new_resource . path ) } .sock"
88+ end
89+
7990 # Set service resource options.
8091 def service_options ( resource )
8192 super
82- resource . ruby_command ( "unicorn --port #{ new_resource . port } #{ configru_path } " )
93+ unless new_resource . socket
94+ resource . ruby_command ( "unicorn --port #{ new_resource . port } #{ configru_path } " )
95+ else
96+ resource . ruby_command ( "unicorn -l #{ socket_path } #{ configru_path } " )
97+ end
8398 end
8499 end
85100 end
You can’t perform that action at this time.
0 commit comments