Skip to content

Commit

Permalink
Fix Cloud Logging (#1235)
Browse files Browse the repository at this point in the history
* Add the env var to the supervisord processes.
* Add some logging.
  • Loading branch information
wtgee authored Apr 4, 2024
1 parent eee1cda commit b4cd758
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion conf_files/pocs-supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
chown=panoptes:panoptes

[supervisord]
environment=USER="panoptes",HOME="/home/panoptes",PATH="$PATH:/home/panoptes/conda/envs/conda-pocs/bin"
environment=
USER="panoptes",
HOME="/home/panoptes",
PATH="$PATH:/home/panoptes/conda/envs/conda-pocs/bin",
GOOGLE_APPLICATION_CREDENTIALS="/home/panoptes/keys/panoptes-upload-key.json"

[program:pocs-config-server]
priority=1
Expand Down
2 changes: 1 addition & 1 deletion src/panoptes/pocs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from panoptes.pocs import hardware
from panoptes.pocs.utils.logger import get_logger
from panoptes.utils.config import client
from panoptes.utils.database import PanDB
from panoptes.pocs.utils.database import PocsDB as PanDB
from requests.exceptions import ConnectionError

# Global database.
Expand Down
3 changes: 3 additions & 0 deletions src/panoptes/pocs/utils/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def check_firestore(self):

self.use_firestore = get_config('panoptes_network.use_firestore', default=False)
if self.use_firestore:
logger.info('Setting up Firestore connection')
self.firestore_db = firestore.Client()
else:
self.firestore_db = None
Expand All @@ -49,8 +50,10 @@ def insert_current(self, collection, obj, store_permanently=True):
metadata = dict(collection=collection, received_time=firestore.SERVER_TIMESTAMP, **obj)

try:
logger.debug(f'Inserting into firestore: {fs_key!r} {metadata}')
doc_ref = self.firestore_db.document(fs_key)
doc_ref.set(metadata)
logger.debug(f'Inserted into firestore: {doc_ref.id}')
except Exception as e:
logger.warning(f'Problem inserting firestore record: {e!r}')

Expand Down

0 comments on commit b4cd758

Please sign in to comment.