Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
richardr1126 committed Dec 13, 2024
1 parent 672d3b6 commit d611363
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
web: gunicorn web.app:app --bind 0.0.0.0:8000 --workers 2
web: gunicorn web.app:app --bind 0.0.0.0:8000 --workers 4
firehose: python start_stream.py
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Open `.env` in your preferred text editor and fill in the necessary variables.
Build and run Docker image:
```shell
docker build -t myfeed .
docker build --rm -t myfeed .
docker run --rm -it --env-file .env -p 8000:8000 -v feeddata:/var/data/ myfeed
```

Expand Down
7 changes: 5 additions & 2 deletions firehose/data_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def _run(name, operations_callback, stream_stop_event=None):
SubscriptionState.create(service=name, cursor=0)

# Initialize the firehose client w/o a cursor for now
client = FirehoseSubscribeReposClient()
client = FirehoseSubscribeReposClient(params)

def on_message_handler(message: firehose_models.MessageFrame) -> None:
"""
Expand Down Expand Up @@ -156,7 +156,10 @@ def on_message_handler(message: firehose_models.MessageFrame) -> None:
# Update the client's parameters with the new cursor
client.update_params(models.ComAtprotoSyncSubscribeRepos.Params(cursor=commit.seq))
# Persist the new cursor in the database
#SubscriptionState.update(cursor=commit.seq).where(SubscriptionState.service == name).execute()
try:
SubscriptionState.update(cursor=commit.seq).where(SubscriptionState.service == name).execute()
except Exception as e:
logger.error(f"Failed to update cursor in database: {e}")

if not commit.blocks:
# Skip if there are no blocks to process
Expand Down
2 changes: 0 additions & 2 deletions web/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ def describe_feed_generator():
@app.route('/xrpc/app.bsky.feed.getFeedSkeleton', methods=['GET'])
def get_feed_skeleton():
feed = request.args.get('feed', default=None, type=str)
logger.info(f'Feed: {feed}')
algo = algos.get(feed)
logger.info(f'Algos: {algos}')
if not algo:
return 'Unsupported algorithm', 400

Expand Down

0 comments on commit d611363

Please sign in to comment.