Skip to content

Commit 17e2c03

Browse files
Merge pull request #133 from blacklanternsecurity/rename-watchdog
Rename watchdog -> worker
2 parents 4ce6960 + b7eeb04 commit 17e2c03

38 files changed

Lines changed: 120 additions & 120 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ bbctl server start
4848

4949
## Deploy with Helm (Kubernetes)
5050

51-
BBOT Server can be deployed to Kubernetes using its official Helm chart. The chart deploys the API server, watchdog, MongoDB, and Redis.
51+
BBOT Server can be deployed to Kubernetes using its official Helm chart. The chart deploys the API server, worker, MongoDB, and Redis.
5252

5353
### Quick Start
5454

bbot_server/applets/base.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ def decorator(fn):
4949
return decorator
5050

5151

52-
def watchdog_task(**kwargs):
52+
def worker_task(**kwargs):
5353
"""
54-
Decorate your applet method with this to make it a watchdog task
54+
Decorate your applet method with this to make it a worker task
5555
"""
5656

5757
def decorator(fn):
5858
fn._kwargs = kwargs
59-
fn._watchdog_task = True
59+
fn._worker_task = True
6060
return fn
6161

6262
return decorator
@@ -240,8 +240,8 @@ async def _native_setup(self):
240240
self.task_broker = await self.message_queue.make_taskiq_broker()
241241
await self.task_broker.startup()
242242

243-
# register watchdog tasks
244-
await self.register_watchdog_tasks(self.task_broker)
243+
# register worker tasks
244+
await self.register_worker_tasks(self.task_broker)
245245

246246
if self.name != "Root Applet":
247247
try:
@@ -290,15 +290,15 @@ async def reconcile_all_indexes(self):
290290
diff = compute_index_diff(desired, desired_text, existing, existing_text)
291291
await apply_index_diff(collection, diff, existing)
292292

293-
async def register_watchdog_tasks(self, broker):
294-
# register watchdog tasks
293+
async def register_worker_tasks(self, broker):
294+
# register worker tasks
295295
methods = {name: member for name, member in getmembers(self) if callable(member)}
296296
for method_name, method in methods.items():
297297
# handle case where tasks have already been registered
298298
method = getattr(method, "original_func", method)
299299

300-
_watchdog_task = getattr(method, "_watchdog_task", None)
301-
if _watchdog_task is None:
300+
_worker_task = getattr(method, "_worker_task", None)
301+
if _worker_task is None:
302302
continue
303303
kwargs = getattr(method, "_kwargs", {})
304304
# crontab handling

bbot_server/modules/emails/emails_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# from bbot_server.watchdogs.emails import EmailWatchdog
1+
# from bbot_server.workers.emails import EmailWorker
22
from bbot_server.applets.base import BaseApplet, api_endpoint, BaseModel, Field
33

44

@@ -7,7 +7,7 @@ class EmailsApplet(BaseApplet):
77
description = "emails discovered during scans"
88
# watched_events = ["EMAIL_ADDRESS"]
99
route_prefix = ""
10-
# watchdogs = [EmailWatchdog]
10+
# workers = [EmailWorker]
1111
attach_to = "assets"
1212

1313
class AssetFields(BaseModel):

bbot_server/modules/events/events_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async def insert_event(self, event: Event):
2929
Insert a BBOT event into the asset database
3030
"""
3131
# publish event to the message queue
32-
# it will be picked up by the watchdog and ingested
32+
# it will be picked up by the worker and ingested
3333
await self.root.message_queue.publish_event(event)
3434

3535
@api_endpoint("/get/{uuid}", methods=["GET"], summary="Get an event by its UUID")

bbot_server/modules/server/server_cli.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def start(
2828
api_only: Annotated[
2929
bool, Option("--api-only", "-a", help="Only start the REST API, without Docker Compose")
3030
] = False,
31-
watchdog_only: Annotated[
32-
bool, Option("--watchdog-only", "-w", help="Only start the watchdog, without Docker Compose")
31+
worker_only: Annotated[
32+
bool, Option("--worker-only", "-w", help="Only start the worker, without Docker Compose")
3333
] = False,
3434
listen: Annotated[str, Option("--listen", "-l", help="Listen address", metavar="IP_ADDRESS")] = "127.0.0.1",
3535
port: Annotated[int, Option("--port", "-p", help="Port to run the server on", metavar="PORT")] = 8807,
@@ -60,30 +60,30 @@ def start(
6060
workers=1,
6161
)
6262

63-
elif watchdog_only:
64-
print("Starting watchdog")
63+
elif worker_only:
64+
print("Starting worker")
6565

66-
async def run_watchdog():
66+
async def run_worker():
6767
try:
6868
from bbot_server import BBOTServer
69-
from bbot_server.watchdog import BBOTWatchdog
69+
from bbot_server.worker import BBOTWorker
7070

7171
bbot_server = BBOTServer()
7272
await bbot_server.setup()
7373

74-
watchdog = BBOTWatchdog(bbot_server)
75-
await watchdog.start()
76-
print("Watchdog successfully started")
74+
worker = BBOTWorker(bbot_server)
75+
await worker.start()
76+
print("Worker successfully started")
7777

7878
# sleep for infinity
7979
event = asyncio.Event()
8080
await event.wait()
8181

8282
except KeyboardInterrupt:
8383
with suppress(Exception):
84-
await watchdog.stop()
84+
await worker.stop()
8585

86-
asyncio.run(run_watchdog())
86+
asyncio.run(run_worker())
8787

8888
else:
8989
# initialize the config if not already

bbot_server/watchdog/__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

bbot_server/worker/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .worker import BBOTWorker
2+
3+
__all__ = ["BBOTWorker"]
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from bbot_server.modules.activity.activity_models import Activity
1313

1414

15-
class BBOTWatchdog:
15+
class BBOTWorker:
1616
"""
1717
Contains:
1818
- taskiq worker
@@ -40,9 +40,9 @@ async def startup(state: TaskiqState) -> None:
4040

4141
await self.broker.startup()
4242

43-
# register watchdog tasks
43+
# register worker tasks
4444
for app in self.bbot_server.all_child_applets(include_self=True):
45-
await app.register_watchdog_tasks(self.broker)
45+
await app.register_worker_tasks(self.broker)
4646

4747
# taskiq worker tasks
4848
self.taskiq_worker_task = asyncio.create_task(run_receiver_task(self.broker))
@@ -157,7 +157,7 @@ async def _get_or_create_asset(self, host: str, event: Event = None, parent_acti
157157
return asset, activities
158158

159159
async def stop(self) -> None:
160-
self.log.info("Stopping watchdog")
160+
self.log.info("Stopping worker")
161161
await self.bbot_server.message_queue.unsubscribe(self.event_listener)
162162
self.taskiq_worker_task.cancel()
163163
self.taskiq_scheduler_task.cancel()

compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ services:
2525
- mongodb
2626
- redis
2727

28-
watchdog:
28+
worker:
2929
<<: *bbot-server-base
30-
command: ["bbctl", "server", "start", "--watchdog-only"]
30+
command: ["bbctl", "server", "start", "--worker-only"]
3131
depends_on:
3232
server:
3333
condition: service_healthy

helm/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
22
name: bbot-server
3-
description: Helm chart for BBOT Server (API + Watchdog)
3+
description: Helm chart for BBOT Server (API + Worker)
44
type: application
55
version: 0.1.0
66
appVersion: "0.1.0"

0 commit comments

Comments
 (0)