functions_framework 1.4.2 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72dfd786bcd5b46663c5bb00f78fd6eed556f8cb9419f7aebeb1fc16421d61b4
4
- data.tar.gz: 16ef142b7cc6c98b0eb42c5e6df6fb9d8deceee28d582b2bc0a859b20ef0b97b
3
+ metadata.gz: 7dc90045c947a92ef29d14a88cccc1a31c82969912b7eca410ff7423bea52cc1
4
+ data.tar.gz: f678ef25e7883451be774b9dffacb8538971cd6d2211dfeac6a9f7886803ca5f
5
5
  SHA512:
6
- metadata.gz: 1f1eeb41025962565b9e6920848d0eb117467a60ccea937c415a963281014c35762d6c66966bd281d2e3e2c9937e9d5d2772884ed79d43ce1da690428c3380da
7
- data.tar.gz: be1032875299ba2e18a189d142b4a654bb338ec0d9455757c11088baf0c6d5b71d189a166552c9243f14b562fe1d649ca4839bcb24a3a3ac75eca84df3006c2d
6
+ metadata.gz: c148723f894e7b341780fd43f32938e96fa8de48fca7e8e60f25def589de0fcd05433508e25c756617bcf7bcd58a98793cd0a8112974fd4d4c9cc65aceaa728f
7
+ data.tar.gz: b0913575ae419000ca0ea74b9f70cea6ecd96126955b27ffb27887b55d90f3abf5f84e5bfafd87c419f960cb683a92118c62252394c79be631cd407057ae43d9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ### 1.5.0 (2025-01-03)
4
+
5
+ #### Features
6
+
7
+ * Support pidfile in CLI & Server (defaults to puma.pid) ([#178](https://github.com/GoogleCloudPlatform/functions-framework-ruby/issues/178))
8
+
3
9
  ### 1.4.2 (2024-09-18)
4
10
 
5
11
  #### Bug Fixes
data/README.md CHANGED
@@ -4,8 +4,7 @@ An open source framework for writing lightweight, portable Ruby functions that
4
4
  run in a serverless environment. Functions written to this Framework will run
5
5
  in many different environments, including:
6
6
 
7
- * [Google Cloud Functions](https://cloud.google.com/functions)
8
- * [Google Cloud Run](https://cloud.google.com/run)
7
+ * [Google Cloud Run functions](https://cloud.google.com/functions)
9
8
  * Any other [Knative](https://github.com/knative)-based environment
10
9
  * Your local development machine
11
10
 
@@ -113,8 +112,7 @@ These guides provide additional getting-started information.
113
112
  functions server.
114
113
  * **[Deploying Functions](https://googlecloudplatform.github.io/functions-framework-ruby/latest/file.deploying-functions.html)**
115
114
  : How to deploy functions to
116
- [Google Cloud Functions](https://cloud.google.com/functions) or
117
- [Google Cloud Run](https://cloud.google.com/run).
115
+ [Google Cloud Run functions](https://cloud.google.com/functions)
118
116
 
119
117
  The library reference documentation can be found at:
120
118
  https://googlecloudplatform.github.io/functions-framework-ruby
@@ -36,6 +36,7 @@ module FunctionsFramework
36
36
  @source = ::ENV["FUNCTION_SOURCE"] || ::FunctionsFramework::DEFAULT_SOURCE
37
37
  @env = nil
38
38
  @port = nil
39
+ @pidfile = nil
39
40
  @bind = nil
40
41
  @min_threads = nil
41
42
  @max_threads = nil
@@ -67,6 +68,12 @@ module FunctionsFramework
67
68
  #
68
69
  attr_reader :error_message
69
70
 
71
+ ##
72
+ # @return [String] The pidfile.
73
+ # @return [nil] if not running.
74
+ #
75
+ attr_reader :pidfile
76
+
70
77
  ##
71
78
  # Parse the given command line arguments.
72
79
  # Exits if argument parsing failed.
@@ -89,6 +96,9 @@ module FunctionsFramework
89
96
  "Supported values are 'http' and 'cloudevent'." do |val|
90
97
  @signature_type = val
91
98
  end
99
+ op.on "-P", "--pidfile PIDFILE", "Set the pidfile for the server (defaults to puma.pid)" do |val|
100
+ @pidfile = val
101
+ end
92
102
  op.on "-p", "--port PORT", "Set the port to listen to (defaults to 8080)" do |val|
93
103
  @port = val.to_i
94
104
  end
@@ -218,6 +228,7 @@ module FunctionsFramework
218
228
  ::FunctionsFramework.start function do |config|
219
229
  config.rack_env = @env
220
230
  config.port = @port
231
+ config.pidfile = @pidfile
221
232
  config.bind_addr = @bind
222
233
  config.show_error_details = @detailed_errors
223
234
  config.min_threads = @min_threads
@@ -152,6 +152,24 @@ module FunctionsFramework
152
152
  @server&.thread&.alive?
153
153
  end
154
154
 
155
+ ##
156
+ # Returns pidfile if server is currently running
157
+ #
158
+ # @return [String, nil]
159
+ #
160
+ def pidfile
161
+ @config.pidfile if running?
162
+ end
163
+
164
+ ##
165
+ # Returns whether pidfile is present.
166
+ #
167
+ # @return [Boolean]
168
+ #
169
+ def pidfile?
170
+ !!@config.pidfile && running?
171
+ end
172
+
155
173
  ##
156
174
  # Cause this server to respond to SIGTERM, SIGINT, and SIGHUP by shutting
157
175
  # down gracefully.
@@ -214,6 +232,7 @@ module FunctionsFramework
214
232
  self.rack_env = nil
215
233
  self.bind_addr = nil
216
234
  self.port = nil
235
+ self.pidfile = nil
217
236
  self.min_threads = nil
218
237
  self.max_threads = nil
219
238
  self.show_error_details = nil
@@ -245,6 +264,14 @@ module FunctionsFramework
245
264
  @port = (port || ::ENV["PORT"] || 8080).to_i
246
265
  end
247
266
 
267
+ ##
268
+ # Set the pidfile string, or `nil` to use the default.
269
+ # @param path [String,nil]
270
+ #
271
+ def pidfile= path
272
+ @pidfile = (path || ::ENV["PIDFILE"] || "puma.pid").to_s
273
+ end
274
+
248
275
  ##
249
276
  # Set the minimum number of worker threads, or `nil` to use the default.
250
277
  # @param min_threads [Integer,nil]
@@ -306,6 +333,14 @@ module FunctionsFramework
306
333
  @port
307
334
  end
308
335
 
336
+ ##
337
+ # Returns the current pidfile string.
338
+ # @return [String]
339
+ #
340
+ def pidfile
341
+ @pidfile
342
+ end
343
+
309
344
  ##
310
345
  # Returns the minimum number of worker threads in the thread pool.
311
346
  # @return [Integer]
@@ -17,5 +17,5 @@ module FunctionsFramework
17
17
  # Version of the Ruby Functions Framework
18
18
  # @return [String]
19
19
  #
20
- VERSION = "1.4.2".freeze
20
+ VERSION = "1.5.0".freeze
21
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: functions_framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Azuma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-01 00:00:00.000000000 Z
11
+ date: 2025-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cloud_events
@@ -106,10 +106,10 @@ homepage: https://github.com/GoogleCloudPlatform/functions-framework-ruby
106
106
  licenses:
107
107
  - Apache-2.0
108
108
  metadata:
109
- changelog_uri: https://googlecloudplatform.github.io/functions-framework-ruby/v1.4.2/file.CHANGELOG.html
109
+ changelog_uri: https://googlecloudplatform.github.io/functions-framework-ruby/v1.5.0/file.CHANGELOG.html
110
110
  source_code_uri: https://github.com/GoogleCloudPlatform/functions-framework-ruby
111
111
  bug_tracker_uri: https://github.com/GoogleCloudPlatform/functions-framework-ruby/issues
112
- documentation_uri: https://googlecloudplatform.github.io/functions-framework-ruby/v1.4.2
112
+ documentation_uri: https://googlecloudplatform.github.io/functions-framework-ruby/v1.5.0
113
113
  post_install_message:
114
114
  rdoc_options: []
115
115
  require_paths:
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
- rubygems_version: 3.5.6
128
+ rubygems_version: 3.5.23
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: Functions Framework for Ruby