1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
Commit graph

27 commits

Author SHA1 Message Date
Robin Wallin
0256d71e60
Rename Puma::JSON to Puma::JSONSerialization (#2640)
In the context of user-defined hooks (e.g. in `before_fork`), the previous naming had the unfortunate side-effect of causing `JSON` to resolve to `Puma::JSON` rather than, the likely more expected, `::JSON` module.

Closes #2639
2021-06-09 08:55:45 -06:00
MSP-Greg
fac83ae35a
Add support for Linux's abstract sockets (#2564)
* Support Linux's abstract sockets

Closes #2526

* Add two simple UNIXSocket tests
2021-04-24 17:24:44 -06:00
MSP-Greg
51ea1b44ea
Update helper.rb TestSkips, add HAS_UNIX_SOCKET to puma.rb [changelog skip] (#2576)
* Update helper.rb TestSkips, add HAS_UNIX_SOCKET to puma.rb

* Tests - skip updates

* test_integration_cluster.rb - fix some test warnings & RuboCop
2021-03-15 08:10:43 -06:00
MSP-Greg
37f47cad94
Move ssl detection to puma.rb (#2541)
puma.rb loads puma/puma_http11, which contains the compiled c code for ssl.  Move ssl detection from puma/detect.rb to puma.rb
2021-02-01 14:10:28 -07:00
Chris LaRose
64c0153cd0
Remove use of json gem (#2479)
* Add basic JSON serializer

For now, it only handles Arrays of Integers, but we'll extend it to
support all of the common types

* Serialize Strings

* Escape quotes in Strings

* Escape backslashes in Strings

* Serialize Hashes with String keys

* Extract method for serializing Strings

* Add test coverage for non-Hash non-Array JSON serialization

* Add test for unexpected key types

* Serialize Hashes with Symbol keys

* Raise on unexpected value types

* Serialize boolean values

* Serialize Floats

* Add module comment to Puma::JSON

* Update integration test to use fully-qualfied JSON module reference

* Remove json gem dependency from /stats status server response

Fixes a bug where requesting `/stats` from the status server would cause
subsequent phased restarts to fail when upgrading/downgrading the json
gem.

* Run gc_stats tests on JRuby

These were disabled at some point on JRuby, but they seem to run fine.
Importantly, this test ensures that a call to `/gc-stats` returns
well-formed JSON on JRuby, where the value of `GC.stat` contains nested
structures.

* Remove json gem dependency from /gc-stats status server response

Fixes a bug where requesting `/gc-stats` from the status server would cause
subsequent phased restarts to fail when upgrading/downgrading the json
gem.

* Remove json gem from /thread-backtraces status server response

Fixes a bug where requesting `/thread-backtraces` from the status server
would cause subsequent phased restarts to fail when
upgrading/downgrading the json gem.

* Remove json gem dependency from Puma.stats

Fixes a bug where accessing `Puma.stats` would cause subsequent phased
restarts to fail when upgrading/downgrading the json gem.

* Fix test name in json test

Co-authored-by: rmacklin <1863540+rmacklin@users.noreply.github.com>

* Add History entry

* Add test for exceptions on values of unexpected types

* Update test name for additional clarity

* Reorder cases to match order in ECMA-404

* Allow all serializable inputs in Puma::JSON::serialize

The pervious implementation was based on and older JSON standard which
defined JSON texts to be either objects or arrays. Modern JSON standands
allow all JSON values to be valid JSON texts.

* Update JSON tests to test value types directly

* Reorder tests to roughly match source order

* Add test for serializing integers as JSON

* Serialize nil as null

* Use block form of gsub instead of hash form

* Escape control characters as required by ECMA-404

* Collapse handling of Symbol and String into one case

* Extract constants used in string serialization

* Remove superflous else case

* Use stringio for incremental JSON construction

* Extract test helper for testing JSON serialization

* Assert that strings generated by Puma::JSON roundtrip when using ::JSON

* Use a recent version of the json gem in tests

`::JSON.parse` doesn't handle JSON texts other than objects and arrays
in old versions

* Handle default expected_roundtrip more explicitly for clarity

Co-authored-by: rmacklin <1863540+rmacklin@users.noreply.github.com>
2020-11-10 10:16:42 -07:00
MSP-Greg
4e78060385
Add more @!attribute tags [skip ci] (#2385) 2020-09-25 12:50:57 -06:00
Jörg Schray
93bb1d0174
Fix LoadError in CentOS 8 (#2381)
'require_relative' breaks gem install on CentOS 8 and should not be necessary with recent version of rubygems
2020-09-24 11:07:54 -06:00
MSP-Greg
038a0d9da9
Documentation - add version info, misc fixes [ci skip] (#2368) 2020-09-17 09:15:19 -06:00
MSP-Greg
b1c760a122
Adjust code for compiling without SSL (MRI & JRuby), add SSL detection 2020-09-14 12:20:00 -05:00
MSP-Greg
fe31aadd5b Load JSON at runtime
Closes #2206
2020-05-17 11:59:39 -05:00
Richard Schneeman
095964879b
Revert api change from #2086 introduce Puma.stats_hash api (#2253)
* Revert api change from #2086 introduce Puma.stats_hash api

The change in #2086 is not backwards compatible with existing gems that parse the output of Puma.stats such as barnes.

Releasing a version of puma with this change would break anyone using the Barnes app and only in production. I'm proposing to keep the existing interface and instead add a new API. This buys us all the features of #2086 without causing any production facing downtime by customers due to API incompatibilities.

Unfortunately it requires that we serialize and the de-serialize the values. One prior benefit of returning json in a string was that it allowed an end user to de-serialize using a faster json algorithm such as `oj` via the "multi json" gem. But the performance penalty will be better than a stability break.
2020-05-11 10:20:19 +09:00
Nate Berkopec
efb1dbfd71
All Puma threads are named (#1968) 2019-09-15 10:52:34 +02:00
Nate Berkopec
4c85facff3
Test cleanup and parallelization (#1846)
* Add frozen string literal everywhere it wasnt already

* Enforce stopgap for tests

* Small amount of integration test cleanup

* Parallelize and freeze Test_app_status

* Big cleanup for test_binder

* Whitespace fix
2019-07-16 18:53:28 -04:00
schneems
441a42e185 Expose top level Puma.stats API
Right now to get stats for a puma process the only way is to go through the control server. The puma-stats-logger does this by reading in a state file then querying the control server manually.

7ad7798e9d/lib/puma_stats_logger/middleware.rb (L28)

Instead, I’m proposing adding a top level `Puma.stats` method that will allow anyone inside of the same process to get access to the stats.

This could be instrumented by a gem to theoretically export these stats to say a Heroku dashboard where we could list out backlog or thread count.

The format of stats is a hash, and will change depending on if the server is in “single” or “clustered” mode.

Clustered:

```
{ "workers": 2, "phase": 0, "booted_workers": 2, "old_workers": 0, "worker_status": [{ "pid": 19832, "index": 0, "phase": 0, "booted": true, "last_checkin": "2018-03-12T16:03:12Z", "last_status": { "backlog":0, "running":5 } },{ "pid": 19833, "index": 1, "phase": 0, "booted": true, "last_checkin": "2018-03-12T16:03:12Z", "last_status": { "backlog":0, "running":5 } }] }
```

Single:

```
{ "backlog": 0, "running": 2 }
```

Alternatively if we could somehow enable another process to get these stats from Puma via pumactl by default without requiring any additional in app config, that would also work.
2018-03-20 11:24:32 -05:00
Francesco Rodriguez
ea22ade352 Require StateFile if needed. 2016-09-08 17:46:24 +02:00
Evan Phoenix
5fdf337790 Move puma.rb to just autoloads. Fixes #1063 2016-09-05 11:29:16 -07:00
schneems
182c836869 Initial Seperation of CLI and Server Launcher work
This is a WIP. This was the minimum I could do to get all tests to pass without changing any tests. Eventually I think we want all high level process controls to come from launcher, I also think we want another separate object that gets passed to Runner/Single/Cluster that will maintain a relationship with the Launcher. We could use this as the object that also gets exposed to the app like the Embeddable class we talked about earlier. 

Moving forwards i'm planning to port out the CLI tests to only test that they are parsing the correct config and launching servers. I'll port all low level unit tests over to the launcher. Making this change we could either keep all the public methods in CLI that delegate to `@launcher`, I'm guessing not many people are using the internals of CLI and we can take them out. It's your call though.

Wanted to kick this over the fence and see if you had any strong reactions or feelings about this approach.
2016-02-04 16:55:10 -06:00
Luis Lavena
9470937da9 Remove non-required dirs from $LOAD_PATH 2012-01-08 16:48:51 -03:00
Evan Phoenix
4439cfb6f8 Remove another ref to a file that doesn't exist 2011-12-01 15:58:54 -08:00
Evan Phoenix
eaa77ebb25 Remove require of deleted file 2011-12-01 15:54:28 -08:00
Evan Phoenix
2e414fbf78 Remove Configurator, not necessary anymore 2011-09-27 11:07:56 -07:00
Evan Phoenix
a3fc7ec951 Simplify, remove GemPlugin usage 2011-09-27 09:23:03 -07:00
Evan Phoenix
e9175fa559 Rename the optional gem loader what it is, optional. 2011-09-23 23:39:35 -07:00
Evan Phoenix
340d2fbf8e Remove HttpRequest via simplification 2011-09-23 23:26:13 -07:00
Evan Phoenix
f5ecd5dca6 More cleanup and removal 2011-09-23 20:46:33 -07:00
Evan Phoenix
000deba3c1 Prune out custom handlers, rack rules. 2011-09-22 22:14:39 -07:00
Evan Phoenix
190a81c55a Name change: Mongrel => Puma 2011-09-22 19:24:43 -07:00