Skip to content

Commit

Permalink
Merge pull request #314 from DigitalSlideArchive/better-error-logging
Browse files Browse the repository at this point in the history
When a bash or pip command fails, better report it
  • Loading branch information
manthey committed Jan 31, 2024
2 parents da3dc3e + 10e5679 commit 04eac8a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ ansible/roles/girder.mongodb
ansible/sample*.cfg
docker-compose.local.yml
worker.local.cfg
docs/.bundle
30 changes: 25 additions & 5 deletions devops/dsa/provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,20 @@ def preprovision(opts):
for entry in opts.pip:
cmd = 'pip install %s' % entry
logger.info('Installing: %s', cmd)
subprocess.check_call(cmd, shell=True)
try:
subprocess.check_call(cmd, shell=True)
except Exception:
logger.error(f'Failed to run {cmd}')
raise
if getattr(opts, 'shell', None) and len(opts.shell):
for entry in opts.shell:
cmd = entry
logger.info('Running: %s', cmd)
subprocess.check_call(cmd, shell=True)
try:
subprocess.check_call(cmd, shell=True)
except Exception:
logger.error(f'Failed to run {cmd}')
raise
if getattr(opts, 'rebuild-client', None):
cmd = 'girder build'
if str(getattr(opts, 'rebuild-client', None)).lower().startswith('dev'):
Expand All @@ -233,7 +241,11 @@ def preprovision(opts):
cmd = ('NPM_CONFIG_FUND=false NPM_CONFIG_AUDIT=false '
'NPM_CONFIG_AUDIT_LEVEL=high NPM_CONFIG_LOGLEVEL=error '
'NPM_CONFIG_PROGRESS=false NPM_CONFIG_PREFER_OFFLINE=true ' + cmd)
subprocess.check_call(cmd, shell=True)
try:
subprocess.check_call(cmd, shell=True)
except Exception:
logger.error(f'Failed to run {cmd}')
raise


def clean_delete_locks():
Expand Down Expand Up @@ -328,12 +340,20 @@ def preprovision_worker(opts):
for entry in settings['pip']:
cmd = 'pip install %s' % entry
logger.info('Installing: %s', cmd)
subprocess.check_call(cmd, shell=True)
try:
subprocess.check_call(cmd, shell=True)
except Exception:
logger.error(f'Failed to run {cmd}')
raise
if settings.get('shell') and len(settings['shell']):
for entry in settings['shell']:
cmd = entry
logger.info('Running: %s', cmd)
subprocess.check_call(cmd, shell=True)
try:
subprocess.check_call(cmd, shell=True)
except Exception:
logger.error(f'Failed to run {cmd}')
raise


def provision_worker(opts):
Expand Down
21 changes: 21 additions & 0 deletions devops/singularity-minimal/singularity-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
version: '2.0'
instances:
girder:
image: "docker://dsarchive/dsa_common"
name: girder
# restart: unless-stopped
volumes:
- ./assetstore:/assetstore
- ./girder.cfg:/etc/girder.cfg
depends_on:
- mongodb
command:
bash -c 'python provision.py --sample-data && girder serve'
mongodb:
image: "docker://mongo:latest"
name: mongodb
# restart: unless-stopped
command: --nojournal
volumes:
- ./db:/data/db

0 comments on commit 04eac8a

Please sign in to comment.