fractor 0.1.4 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop-https---raw-githubusercontent-com-riboseinc-oss-guides-main-ci-rubocop-yml +552 -0
- data/.rubocop.yml +14 -8
- data/.rubocop_todo.yml +284 -43
- data/README.adoc +111 -950
- data/docs/.lycheeignore +16 -0
- data/docs/Gemfile +24 -0
- data/docs/README.md +157 -0
- data/docs/_config.yml +151 -0
- data/docs/_features/error-handling.adoc +1192 -0
- data/docs/_features/index.adoc +80 -0
- data/docs/_features/monitoring.adoc +589 -0
- data/docs/_features/signal-handling.adoc +202 -0
- data/docs/_features/workflows.adoc +1235 -0
- data/docs/_guides/continuous-mode.adoc +736 -0
- data/docs/_guides/cookbook.adoc +1133 -0
- data/docs/_guides/index.adoc +55 -0
- data/docs/_guides/pipeline-mode.adoc +730 -0
- data/docs/_guides/troubleshooting.adoc +358 -0
- data/docs/_pages/architecture.adoc +1390 -0
- data/docs/_pages/core-concepts.adoc +1392 -0
- data/docs/_pages/design-principles.adoc +862 -0
- data/docs/_pages/getting-started.adoc +290 -0
- data/docs/_pages/installation.adoc +143 -0
- data/docs/_reference/api.adoc +1080 -0
- data/docs/_reference/error-reporting.adoc +670 -0
- data/docs/_reference/examples.adoc +181 -0
- data/docs/_reference/index.adoc +96 -0
- data/docs/_reference/troubleshooting.adoc +862 -0
- data/docs/_tutorials/complex-workflows.adoc +1022 -0
- data/docs/_tutorials/data-processing-pipeline.adoc +740 -0
- data/docs/_tutorials/first-application.adoc +384 -0
- data/docs/_tutorials/index.adoc +48 -0
- data/docs/_tutorials/long-running-services.adoc +931 -0
- data/docs/assets/images/favicon-16.png +0 -0
- data/docs/assets/images/favicon-32.png +0 -0
- data/docs/assets/images/favicon-48.png +0 -0
- data/docs/assets/images/favicon.ico +0 -0
- data/docs/assets/images/favicon.png +0 -0
- data/docs/assets/images/favicon.svg +45 -0
- data/docs/assets/images/fractor-icon.svg +49 -0
- data/docs/assets/images/fractor-logo.svg +61 -0
- data/docs/index.adoc +131 -0
- data/docs/lychee.toml +39 -0
- data/examples/api_aggregator/README.adoc +627 -0
- data/examples/api_aggregator/api_aggregator.rb +376 -0
- data/examples/auto_detection/README.adoc +407 -29
- data/examples/auto_detection/auto_detection.rb +9 -9
- data/examples/continuous_chat_common/message_protocol.rb +53 -0
- data/examples/continuous_chat_fractor/README.adoc +217 -0
- data/examples/continuous_chat_fractor/chat_client.rb +303 -0
- data/examples/continuous_chat_fractor/chat_common.rb +83 -0
- data/examples/continuous_chat_fractor/chat_server.rb +167 -0
- data/examples/continuous_chat_fractor/simulate.rb +345 -0
- data/examples/continuous_chat_server/README.adoc +135 -0
- data/examples/continuous_chat_server/chat_client.rb +303 -0
- data/examples/continuous_chat_server/chat_server.rb +359 -0
- data/examples/continuous_chat_server/simulate.rb +343 -0
- data/examples/error_reporting.rb +207 -0
- data/examples/file_processor/README.adoc +170 -0
- data/examples/file_processor/file_processor.rb +615 -0
- data/examples/file_processor/sample_files/invalid.csv +1 -0
- data/examples/file_processor/sample_files/orders.xml +24 -0
- data/examples/file_processor/sample_files/products.json +23 -0
- data/examples/file_processor/sample_files/users.csv +6 -0
- data/examples/hierarchical_hasher/README.adoc +629 -41
- data/examples/hierarchical_hasher/hierarchical_hasher.rb +12 -8
- data/examples/image_processor/README.adoc +610 -0
- data/examples/image_processor/image_processor.rb +349 -0
- data/examples/image_processor/processed_images/sample_10_processed.jpg.json +12 -0
- data/examples/image_processor/processed_images/sample_1_processed.jpg.json +12 -0
- data/examples/image_processor/processed_images/sample_2_processed.jpg.json +12 -0
- data/examples/image_processor/processed_images/sample_3_processed.jpg.json +12 -0
- data/examples/image_processor/processed_images/sample_4_processed.jpg.json +12 -0
- data/examples/image_processor/processed_images/sample_5_processed.jpg.json +12 -0
- data/examples/image_processor/processed_images/sample_6_processed.jpg.json +12 -0
- data/examples/image_processor/processed_images/sample_7_processed.jpg.json +12 -0
- data/examples/image_processor/processed_images/sample_8_processed.jpg.json +12 -0
- data/examples/image_processor/processed_images/sample_9_processed.jpg.json +12 -0
- data/examples/image_processor/test_images/sample_1.png +1 -0
- data/examples/image_processor/test_images/sample_10.png +1 -0
- data/examples/image_processor/test_images/sample_2.png +1 -0
- data/examples/image_processor/test_images/sample_3.png +1 -0
- data/examples/image_processor/test_images/sample_4.png +1 -0
- data/examples/image_processor/test_images/sample_5.png +1 -0
- data/examples/image_processor/test_images/sample_6.png +1 -0
- data/examples/image_processor/test_images/sample_7.png +1 -0
- data/examples/image_processor/test_images/sample_8.png +1 -0
- data/examples/image_processor/test_images/sample_9.png +1 -0
- data/examples/log_analyzer/README.adoc +662 -0
- data/examples/log_analyzer/log_analyzer.rb +579 -0
- data/examples/log_analyzer/sample_logs/apache.log +20 -0
- data/examples/log_analyzer/sample_logs/json.log +15 -0
- data/examples/log_analyzer/sample_logs/nginx.log +15 -0
- data/examples/log_analyzer/sample_logs/rails.log +29 -0
- data/examples/multi_work_type/README.adoc +576 -26
- data/examples/multi_work_type/multi_work_type.rb +30 -29
- data/examples/performance_monitoring.rb +120 -0
- data/examples/pipeline_processing/README.adoc +740 -26
- data/examples/pipeline_processing/pipeline_processing.rb +16 -16
- data/examples/priority_work_example.rb +155 -0
- data/examples/producer_subscriber/README.adoc +889 -46
- data/examples/producer_subscriber/producer_subscriber.rb +20 -16
- data/examples/scatter_gather/README.adoc +829 -27
- data/examples/scatter_gather/scatter_gather.rb +29 -28
- data/examples/simple/README.adoc +347 -0
- data/examples/simple/sample.rb +5 -5
- data/examples/specialized_workers/README.adoc +622 -26
- data/examples/specialized_workers/specialized_workers.rb +88 -45
- data/examples/stream_processor/README.adoc +206 -0
- data/examples/stream_processor/stream_processor.rb +284 -0
- data/examples/web_scraper/README.adoc +625 -0
- data/examples/web_scraper/web_scraper.rb +285 -0
- data/examples/workflow/README.adoc +406 -0
- data/examples/workflow/circuit_breaker/README.adoc +360 -0
- data/examples/workflow/circuit_breaker/circuit_breaker_workflow.rb +225 -0
- data/examples/workflow/conditional/README.adoc +483 -0
- data/examples/workflow/conditional/conditional_workflow.rb +215 -0
- data/examples/workflow/dead_letter_queue/README.adoc +374 -0
- data/examples/workflow/dead_letter_queue/dead_letter_queue_workflow.rb +217 -0
- data/examples/workflow/fan_out/README.adoc +381 -0
- data/examples/workflow/fan_out/fan_out_workflow.rb +202 -0
- data/examples/workflow/retry/README.adoc +248 -0
- data/examples/workflow/retry/retry_workflow.rb +195 -0
- data/examples/workflow/simple_linear/README.adoc +267 -0
- data/examples/workflow/simple_linear/simple_linear_workflow.rb +175 -0
- data/examples/workflow/simplified/README.adoc +329 -0
- data/examples/workflow/simplified/simplified_workflow.rb +222 -0
- data/exe/fractor +10 -0
- data/lib/fractor/cli.rb +288 -0
- data/lib/fractor/configuration.rb +307 -0
- data/lib/fractor/continuous_server.rb +183 -0
- data/lib/fractor/error_formatter.rb +72 -0
- data/lib/fractor/error_report_generator.rb +152 -0
- data/lib/fractor/error_reporter.rb +244 -0
- data/lib/fractor/error_statistics.rb +147 -0
- data/lib/fractor/execution_tracer.rb +162 -0
- data/lib/fractor/logger.rb +230 -0
- data/lib/fractor/main_loop_handler.rb +406 -0
- data/lib/fractor/main_loop_handler3.rb +135 -0
- data/lib/fractor/main_loop_handler4.rb +299 -0
- data/lib/fractor/performance_metrics_collector.rb +181 -0
- data/lib/fractor/performance_monitor.rb +215 -0
- data/lib/fractor/performance_report_generator.rb +202 -0
- data/lib/fractor/priority_work.rb +93 -0
- data/lib/fractor/priority_work_queue.rb +189 -0
- data/lib/fractor/result_aggregator.rb +33 -1
- data/lib/fractor/shutdown_handler.rb +168 -0
- data/lib/fractor/signal_handler.rb +80 -0
- data/lib/fractor/supervisor.rb +430 -144
- data/lib/fractor/supervisor_logger.rb +88 -0
- data/lib/fractor/version.rb +1 -1
- data/lib/fractor/work.rb +12 -0
- data/lib/fractor/work_distribution_manager.rb +151 -0
- data/lib/fractor/work_queue.rb +88 -0
- data/lib/fractor/work_result.rb +181 -9
- data/lib/fractor/worker.rb +75 -1
- data/lib/fractor/workflow/builder.rb +210 -0
- data/lib/fractor/workflow/chain_builder.rb +169 -0
- data/lib/fractor/workflow/circuit_breaker.rb +183 -0
- data/lib/fractor/workflow/circuit_breaker_orchestrator.rb +208 -0
- data/lib/fractor/workflow/circuit_breaker_registry.rb +112 -0
- data/lib/fractor/workflow/dead_letter_queue.rb +334 -0
- data/lib/fractor/workflow/execution_hooks.rb +39 -0
- data/lib/fractor/workflow/execution_strategy.rb +225 -0
- data/lib/fractor/workflow/execution_trace.rb +134 -0
- data/lib/fractor/workflow/helpers.rb +191 -0
- data/lib/fractor/workflow/job.rb +290 -0
- data/lib/fractor/workflow/job_dependency_validator.rb +120 -0
- data/lib/fractor/workflow/logger.rb +110 -0
- data/lib/fractor/workflow/pre_execution_context.rb +193 -0
- data/lib/fractor/workflow/retry_config.rb +156 -0
- data/lib/fractor/workflow/retry_orchestrator.rb +184 -0
- data/lib/fractor/workflow/retry_strategy.rb +93 -0
- data/lib/fractor/workflow/structured_logger.rb +30 -0
- data/lib/fractor/workflow/type_compatibility_validator.rb +222 -0
- data/lib/fractor/workflow/visualizer.rb +211 -0
- data/lib/fractor/workflow/workflow_context.rb +132 -0
- data/lib/fractor/workflow/workflow_executor.rb +669 -0
- data/lib/fractor/workflow/workflow_result.rb +55 -0
- data/lib/fractor/workflow/workflow_validator.rb +295 -0
- data/lib/fractor/workflow.rb +333 -0
- data/lib/fractor/wrapped_ractor.rb +66 -91
- data/lib/fractor/wrapped_ractor3.rb +161 -0
- data/lib/fractor/wrapped_ractor4.rb +242 -0
- data/lib/fractor.rb +93 -3
- metadata +192 -6
- data/tests/sample.rb.bak +0 -309
- data/tests/sample_working.rb.bak +0 -209
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: Signal handling
|
|
4
|
+
nav_order: 3
|
|
5
|
+
---
|
|
6
|
+
== Signal handling
|
|
7
|
+
|
|
8
|
+
== General
|
|
9
|
+
|
|
10
|
+
Fractor provides production-ready signal handling for process control and monitoring. The framework supports different signals depending on the operating system, enabling graceful shutdown and runtime status monitoring.
|
|
11
|
+
|
|
12
|
+
=== Unix signals (Linux, macOS, Unix)
|
|
13
|
+
|
|
14
|
+
==== SIGINT (Ctrl+C)
|
|
15
|
+
|
|
16
|
+
Interactive interrupt signal for graceful shutdown.
|
|
17
|
+
|
|
18
|
+
Usage:
|
|
19
|
+
|
|
20
|
+
* Press `Ctrl+C` in the terminal running Fractor
|
|
21
|
+
* Behavior depends on mode:
|
|
22
|
+
** *Batch mode*: Stops immediately after current work completes
|
|
23
|
+
** *Continuous mode*: Initiates graceful shutdown
|
|
24
|
+
|
|
25
|
+
==== SIGTERM
|
|
26
|
+
|
|
27
|
+
Standard Unix termination signal, preferred for production deployments.
|
|
28
|
+
|
|
29
|
+
This ensures a graceful shutdown of the Fractor supervisor and its workers.
|
|
30
|
+
|
|
31
|
+
Usage:
|
|
32
|
+
|
|
33
|
+
[source,sh]
|
|
34
|
+
----
|
|
35
|
+
kill -TERM <pid>
|
|
36
|
+
# or simply
|
|
37
|
+
kill <pid> # SIGTERM is the default
|
|
38
|
+
----
|
|
39
|
+
|
|
40
|
+
Typical signals from service managers:
|
|
41
|
+
|
|
42
|
+
* Systemd sends SIGTERM on `systemctl stop`
|
|
43
|
+
* Docker sends SIGTERM on `docker stop`
|
|
44
|
+
* Kubernetes sends SIGTERM during pod termination
|
|
45
|
+
|
|
46
|
+
[source,ini]
|
|
47
|
+
----
|
|
48
|
+
# Example systemd service
|
|
49
|
+
[Service]
|
|
50
|
+
ExecStart=/usr/bin/ruby /path/to/fractor_server.rb
|
|
51
|
+
KillMode=process
|
|
52
|
+
KillSignal=SIGTERM
|
|
53
|
+
TimeoutStopSec=30
|
|
54
|
+
----
|
|
55
|
+
|
|
56
|
+
==== SIGUSR1
|
|
57
|
+
|
|
58
|
+
Real-time status monitoring without stopping the process.
|
|
59
|
+
|
|
60
|
+
Usage:
|
|
61
|
+
|
|
62
|
+
[source,sh]
|
|
63
|
+
----
|
|
64
|
+
kill -USR1 <pid>
|
|
65
|
+
----
|
|
66
|
+
|
|
67
|
+
Output example:
|
|
68
|
+
|
|
69
|
+
.Status output
|
|
70
|
+
[example]
|
|
71
|
+
====
|
|
72
|
+
[source]
|
|
73
|
+
----
|
|
74
|
+
==== Fractor Supervisor Status ===
|
|
75
|
+
Mode: Continuous
|
|
76
|
+
Running: true
|
|
77
|
+
Workers: 4
|
|
78
|
+
Idle workers: 2
|
|
79
|
+
Queue size: 15
|
|
80
|
+
Results: 127
|
|
81
|
+
Errors: 3
|
|
82
|
+
----
|
|
83
|
+
====
|
|
84
|
+
|
|
85
|
+
=== Windows signals
|
|
86
|
+
|
|
87
|
+
==== SIGBREAK (Ctrl+Break)
|
|
88
|
+
|
|
89
|
+
Windows alternative to SIGUSR1 for status monitoring.
|
|
90
|
+
|
|
91
|
+
Usage:
|
|
92
|
+
|
|
93
|
+
* Press `Ctrl+Break` in the terminal running Fractor
|
|
94
|
+
* Same output as SIGUSR1 on Unix
|
|
95
|
+
|
|
96
|
+
[NOTE]
|
|
97
|
+
====
|
|
98
|
+
SIGUSR1 is not available on Windows. Use `Ctrl+Break` instead for status monitoring on Windows platforms.
|
|
99
|
+
====
|
|
100
|
+
|
|
101
|
+
=== Signal behavior by mode
|
|
102
|
+
|
|
103
|
+
==== Batch mode
|
|
104
|
+
|
|
105
|
+
In batch processing mode:
|
|
106
|
+
|
|
107
|
+
* SIGINT/SIGTERM: Stops immediately after current work completes
|
|
108
|
+
* SIGUSR1/SIGBREAK: Displays current status
|
|
109
|
+
|
|
110
|
+
==== Continuous mode
|
|
111
|
+
|
|
112
|
+
In continuous mode (long-running servers):
|
|
113
|
+
|
|
114
|
+
* SIGINT/SIGTERM: Graceful shutdown within ~2 seconds
|
|
115
|
+
** Stops accepting new work
|
|
116
|
+
** Completes in-progress work
|
|
117
|
+
** Cleans up resources
|
|
118
|
+
* SIGUSR1/SIGBREAK: Displays current status
|
|
119
|
+
|
|
120
|
+
=== Process monitoring and logging
|
|
121
|
+
|
|
122
|
+
==== Status monitoring and health checks
|
|
123
|
+
|
|
124
|
+
The signals SIGUSR1 (or SIGBREAK on Windows) can be used for health checks.
|
|
125
|
+
|
|
126
|
+
When the signal is received, the supervisor prints its current status to standard output.
|
|
127
|
+
|
|
128
|
+
.Sending the signal
|
|
129
|
+
[example]
|
|
130
|
+
====
|
|
131
|
+
Unix:
|
|
132
|
+
|
|
133
|
+
[source,sh]
|
|
134
|
+
----
|
|
135
|
+
# Send SIGUSR1 to the supervisor process
|
|
136
|
+
kill -USR1 <pid>
|
|
137
|
+
----
|
|
138
|
+
|
|
139
|
+
Windows:
|
|
140
|
+
|
|
141
|
+
[source,sh]
|
|
142
|
+
----
|
|
143
|
+
# Send SIGBREAK to the supervisor process
|
|
144
|
+
kill -BREAK <pid>
|
|
145
|
+
----
|
|
146
|
+
|
|
147
|
+
Output:
|
|
148
|
+
|
|
149
|
+
[source]
|
|
150
|
+
----
|
|
151
|
+
==== Fractor Supervisor Status ===
|
|
152
|
+
Mode: Continuous
|
|
153
|
+
Running: true
|
|
154
|
+
Workers: 4
|
|
155
|
+
Idle workers: 2
|
|
156
|
+
Queue size: 15
|
|
157
|
+
Results: 127
|
|
158
|
+
Errors: 3
|
|
159
|
+
----
|
|
160
|
+
====
|
|
161
|
+
|
|
162
|
+
==== Logging
|
|
163
|
+
|
|
164
|
+
Fractor supports logging of its operations to a specified log file.
|
|
165
|
+
|
|
166
|
+
For ContinuousServer, pass the `log_file` parameter:
|
|
167
|
+
|
|
168
|
+
[source,ruby]
|
|
169
|
+
----
|
|
170
|
+
server = Fractor::ContinuousServer.new(
|
|
171
|
+
worker_pools: [{ worker_class: MyWorker }],
|
|
172
|
+
work_queue: work_queue,
|
|
173
|
+
log_file: 'logs/server.log'
|
|
174
|
+
)
|
|
175
|
+
----
|
|
176
|
+
|
|
177
|
+
For manual Supervisor usage, set the `FRACTOR_LOG_FILE` environment variable before starting your application:
|
|
178
|
+
|
|
179
|
+
[source,sh]
|
|
180
|
+
----
|
|
181
|
+
export FRACTOR_LOG_FILE=/path/to/logs/server.log
|
|
182
|
+
ruby my_fractor_app.rb
|
|
183
|
+
----
|
|
184
|
+
|
|
185
|
+
The log file will contain detailed information about the supervisor's operations, including worker activity, work distribution, results, and errors.
|
|
186
|
+
|
|
187
|
+
.Examples of accessing logs
|
|
188
|
+
[example]
|
|
189
|
+
====
|
|
190
|
+
[source,sh]
|
|
191
|
+
----
|
|
192
|
+
# Check if server is responsive (Unix/Linux/macOS)
|
|
193
|
+
kill -USR1 <pid> && tail -f /path/to/logs/server.log
|
|
194
|
+
|
|
195
|
+
# Monitor with systemd
|
|
196
|
+
systemctl status fractor-server
|
|
197
|
+
journalctl -u fractor-server -f
|
|
198
|
+
|
|
199
|
+
# Monitor with Docker
|
|
200
|
+
docker logs -f <container_id>
|
|
201
|
+
----
|
|
202
|
+
====
|