Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ packages/cloud/
/test_screenshots/
third_party/
packages/stem/workflow.sqlite*
# Local serinus module (gitignored per user)
packages/stem_serinus/
58 changes: 30 additions & 28 deletions packages/dashboard/lib/src/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1031,34 +1031,36 @@ List<DashboardTaskStatusEntry> _applyTaskViewFilters(
final namespaceFilter = options.namespaceFilter?.toLowerCase();
final taskFilter = options.taskFilter?.toLowerCase();
final runFilter = options.runId?.toLowerCase();
return tasks.where((entry) {
if (options.hasFilter) {
final queue = entry.queue.toLowerCase();
if (!(queueFilter != null && queue.contains(queueFilter))) {
return false;
}
}
if (options.hasNamespaceFilter &&
entry.namespace.toLowerCase() != namespaceFilter) {
return false;
}
if (options.hasTaskFilter) {
final name = entry.taskName.toLowerCase();
if (!(taskFilter != null && name.contains(taskFilter))) {
return false;
}
}
if (options.hasRunIdFilter) {
final runId = entry.runId?.toLowerCase() ?? '';
if (!(runFilter != null && runId.contains(runFilter))) {
return false;
}
}
if (options.hasStateFilter && entry.state != options.stateFilter) {
return false;
}
return true;
}).toList(growable: false);
return tasks
.where((entry) {
if (options.hasFilter) {
final queue = entry.queue.toLowerCase();
if (!(queueFilter != null && queue.contains(queueFilter))) {
return false;
}
}
if (options.hasNamespaceFilter &&
entry.namespace.toLowerCase() != namespaceFilter) {
return false;
}
if (options.hasTaskFilter) {
final name = entry.taskName.toLowerCase();
if (!(taskFilter != null && name.contains(taskFilter))) {
return false;
}
}
if (options.hasRunIdFilter) {
final runId = entry.runId?.toLowerCase() ?? '';
if (!(runFilter != null && runId.contains(runFilter))) {
return false;
}
}
if (options.hasStateFilter && entry.state != options.stateFilter) {
return false;
}
return true;
})
.toList(growable: false);
}

String _resolveDefaultNamespace(
Expand Down
5 changes: 3 additions & 2 deletions packages/dashboard/lib/src/services/stem_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ abstract class DashboardDataSource {
Future<DashboardWorkflowRunSnapshot?> fetchWorkflowRun(String runId);

/// Fetches persisted workflow checkpoints, if a workflow store is available.
Future<List<DashboardWorkflowCheckpointSnapshot>>
fetchWorkflowCheckpoints(String runId);
Future<List<DashboardWorkflowCheckpointSnapshot>> fetchWorkflowCheckpoints(
String runId,
);

/// Enqueues a task request through the backing broker.
Future<void> enqueueTask(EnqueueRequest request);
Expand Down
3 changes: 1 addition & 2 deletions packages/dashboard/lib/src/ui/failures.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ ${renderFailuresAlert(options)}
options: DashboardTaskTableOptions(
showState: false,
emptyMessage: 'No individual failures to inspect.',
actionsBuilder: (task) =>
buildTaskReplayAction(task, redirectPath: redirectPath),
actionsBuilder: (task) => buildTaskReplayAction(task, redirectPath: redirectPath),
),
)}
</section>
Expand Down
24 changes: 13 additions & 11 deletions packages/dashboard/lib/src/ui/jobs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ String buildJobsContent({
final jobs = buildJobSummaries(taskStatuses, limit: 500);
final taskFilter = options.task?.toLowerCase();
final queueFilter = options.queue?.toLowerCase();
final filtered = jobs.where((entry) {
final matchesTask =
taskFilter == null ||
taskFilter.isEmpty ||
entry.taskName.toLowerCase().contains(taskFilter);
final matchesQueue =
queueFilter == null ||
queueFilter.isEmpty ||
entry.sampleQueue.toLowerCase().contains(queueFilter);
return matchesTask && matchesQueue;
}).toList(growable: false);
final filtered = jobs
.where((entry) {
final matchesTask =
taskFilter == null ||
taskFilter.isEmpty ||
entry.taskName.toLowerCase().contains(taskFilter);
final matchesQueue =
queueFilter == null ||
queueFilter.isEmpty ||
entry.sampleQueue.toLowerCase().contains(queueFilter);
return matchesTask && matchesQueue;
})
.toList(growable: false);

final total = filtered.fold<int>(0, (sum, entry) => sum + entry.total);
final running = filtered.fold<int>(0, (sum, entry) => sum + entry.running);
Expand Down
24 changes: 11 additions & 13 deletions packages/dashboard/lib/src/ui/overview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ OverviewSections buildOverviewSections(
List<QueueSummary> queues,
List<WorkerStatus> workers,
DashboardThroughput? throughput,
List<DashboardTaskStatusEntry> taskStatuses,
{
String defaultNamespace = 'stem',
}
) {
List<DashboardTaskStatusEntry> taskStatuses, {
String defaultNamespace = 'stem',
}) {
final totalPending = queues.fold<int>(
0,
(total, summary) => total + summary.pending,
Expand Down Expand Up @@ -331,14 +329,14 @@ OverviewSections buildOverviewSections(
'''
<section id="overview-recent-tasks" class="table-card mt-7 ring-1 ring-inset ring-sky-300/10">
${buildTaskStatusTable(
taskStatuses.take(8).toList(growable: false),
options: const DashboardTaskTableOptions(
showAttempt: false,
showError: false,
showActions: false,
emptyMessage: 'No persisted task statuses yet.',
),
)}
taskStatuses.take(8).toList(growable: false),
options: const DashboardTaskTableOptions(
showAttempt: false,
showError: false,
showActions: false,
emptyMessage: 'No persisted task statuses yet.',
),
)}
</section>
''';

Expand Down
3 changes: 1 addition & 2 deletions packages/dashboard/lib/src/ui/tasks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ ${renderTasksAlert(options)}
options: DashboardTaskTableOptions(
emptyMessage: 'No task statuses match the current filters.',
expandableRows: true,
actionsBuilder: (task) =>
buildTaskLifecycleActions(task, redirectPath: taskActionRedirect),
actionsBuilder: (task) => buildTaskLifecycleActions(task, redirectPath: taskActionRedirect),
),
)}
${buildTaskPaginationBar(options, taskStatuses.length)}
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
ormed: ^0.2.0
routed: ^0.3.2
routed_hotwire: ^0.1.2
stem: ^0.2.0
stem: ">=0.2.0-dev <0.3.0"
stem_cli: ^0.1.0
stem_postgres: ^0.1.0
stem_redis: ^0.1.0
Expand Down
6 changes: 6 additions & 0 deletions packages/stem/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.2.1-wip

- Guarded worker and example process signal registration so Windows only
installs supported shutdown watchers, avoiding unsupported `SIGTERM` /
`SIGQUIT` subscriptions during graceful shutdown setup.

## 0.2.0

- Added `StemClient.fromStack(...)` and `StemStack.createClient(...)` so
Expand Down
4 changes: 3 additions & 1 deletion packages/stem/example/autoscaling_demo/bin/worker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ Future<void> main() async {
}

ProcessSignal.sigint.watch().listen(shutdown);
ProcessSignal.sigterm.watch().listen(shutdown);
if (!Platform.isWindows) {
ProcessSignal.sigterm.watch().listen(shutdown);
}

await Completer<void>().future;
}
Expand Down
4 changes: 3 additions & 1 deletion packages/stem/example/daemonized_worker/bin/worker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ Future<void> main(List<String> args) async {
}
}

ProcessSignal.sigterm.watch().listen((_) => complete());
ProcessSignal.sigint.watch().listen((_) => complete());
if (!Platform.isWindows) {
ProcessSignal.sigterm.watch().listen((_) => complete());
}
// #endregion daemonized-worker-signal-handlers

// Simulate background work.
Expand Down
4 changes: 3 additions & 1 deletion packages/stem/example/dlq_sandbox/bin/worker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ Future<void> main() async {
}

ProcessSignal.sigint.watch().listen(shutdown);
ProcessSignal.sigterm.watch().listen(shutdown);
if (!Platform.isWindows) {
ProcessSignal.sigterm.watch().listen(shutdown);
}

await worker.start();
}
4 changes: 3 additions & 1 deletion packages/stem/example/docs_snippets/lib/daemonization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ Future<void> main(List<String> args) async {
}
}

ProcessSignal.sigterm.watch().listen((_) => shutdown());
ProcessSignal.sigint.watch().listen((_) => shutdown());
if (!Platform.isWindows) {
ProcessSignal.sigterm.watch().listen((_) => shutdown());
}
// #endregion daemonization-signal-handlers

// #region daemonization-loop
Expand Down
4 changes: 3 additions & 1 deletion packages/stem/example/ecommerce/bin/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,7 @@ Future<void> main() async {
}

ProcessSignal.sigint.watch().listen(shutdown);
ProcessSignal.sigterm.watch().listen(shutdown);
if (!Platform.isWindows) {
ProcessSignal.sigterm.watch().listen(shutdown);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions packages/stem/example/email_service/bin/enqueuer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Future<void> main(List<String> args) async {
name: 'email.send',
entrypoint: _placeholderEntrypoint,
options: const TaskOptions(queue: 'emails', maxRetries: 3),
),
),
];

final client = await StemClient.fromUrl(
Expand Down Expand Up @@ -82,7 +82,9 @@ Future<void> main(List<String> args) async {
}

ProcessSignal.sigint.watch().listen(shutdown);
ProcessSignal.sigterm.watch().listen(shutdown);
if (!Platform.isWindows) {
ProcessSignal.sigterm.watch().listen(shutdown);
}
}

FutureOr<Object?> _placeholderEntrypoint(
Expand Down
4 changes: 3 additions & 1 deletion packages/stem/example/email_service/bin/worker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ Future<void> main(List<String> args) async {
}

ProcessSignal.sigint.watch().listen(shutdown);
ProcessSignal.sigterm.watch().listen(shutdown);
if (!Platform.isWindows) {
ProcessSignal.sigterm.watch().listen(shutdown);
}
}

Future<String> sendEmail(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ Future<void> main(List<String> args) async {
}

ProcessSignal.sigint.watch().listen(shutdown);
ProcessSignal.sigterm.watch().listen(shutdown);
if (!Platform.isWindows) {
ProcessSignal.sigterm.watch().listen(shutdown);
}

await Completer<void>().future;
}
Expand Down
4 changes: 3 additions & 1 deletion packages/stem/example/image_processor/bin/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ Future<void> main(List<String> args) async {
}

ProcessSignal.sigint.watch().listen(shutdown);
ProcessSignal.sigterm.watch().listen(shutdown);
if (!Platform.isWindows) {
ProcessSignal.sigterm.watch().listen(shutdown);
}
}

FutureOr<Object?> _placeholderEntrypoint(
Expand Down
4 changes: 3 additions & 1 deletion packages/stem/example/image_processor/bin/worker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ Future<void> main(List<String> args) async {
}

ProcessSignal.sigint.watch().listen(shutdown);
ProcessSignal.sigterm.watch().listen(shutdown);
if (!Platform.isWindows) {
ProcessSignal.sigterm.watch().listen(shutdown);
}
}

Future<String> generateThumbnail(
Expand Down
4 changes: 3 additions & 1 deletion packages/stem/example/microservice/beat/bin/beat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ Future<void> main(List<String> args) async {
}

ProcessSignal.sigint.watch().listen(shutdown);
ProcessSignal.sigterm.watch().listen(shutdown);
if (!Platform.isWindows) {
ProcessSignal.sigterm.watch().listen(shutdown);
}

await Completer<void>().future;
}
Expand Down
4 changes: 3 additions & 1 deletion packages/stem/example/microservice/enqueuer/bin/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ Future<void> main(List<String> args) async {
}

ProcessSignal.sigint.watch().listen(shutdown);
ProcessSignal.sigterm.watch().listen(shutdown);
if (!Platform.isWindows) {
ProcessSignal.sigterm.watch().listen(shutdown);
}
}

FutureOr<Object?> _placeholderEntrypoint(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ Future<void> main(List<String> args) async {
}

ProcessSignal.sigint.watch().listen(shutdown);
ProcessSignal.sigterm.watch().listen(shutdown);
if (!Platform.isWindows) {
ProcessSignal.sigterm.watch().listen(shutdown);
}

await Completer<void>().future;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ Future<void> main(List<String> args) async {
}

ProcessSignal.sigint.watch().listen(shutdown);
ProcessSignal.sigterm.watch().listen(shutdown);
if (!Platform.isWindows) {
ProcessSignal.sigterm.watch().listen(shutdown);
}

await Completer<void>().future;
}
Expand Down
Loading
Loading