Skip to content

[troubleshooting] troubleshooting the service

Ingi Erli edited this page Apr 15, 2020 · 24 revisions

Troubleshoot the service

2020-04-14: Machine OS = Ubuntu 18.04.4 LTS (Codename = bionic)

  1. /home/ingierli/repo/swedishbirdrecoveries/docker-compose

Is the service up and running ?

Running make ps should give the following

docker-compose -f docker-compose.prod.yml ps
    Name                   Command               State                    Ports                  
-------------------------------------------------------------------------------------------------
jwilder-proxy   /app/docker-entrypoint.sh  ...   Up      0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp
shiny           /usr/bin/shiny-server.sh         Up      3838/tcp

That says that both services have the 'State' 'Up'

Check the logs for the service

for Shiny

make logs

for proxy

make logs proxy

cron and the update script

runs ./refresh-swedishbirdrecoveries.sh >> ./refresh-swedishbirdrecoveries.log 2>&1

The update script

refresh-swedishbirdrecoveries.sh

#!/bin/bash

docker exec shiny \
Rscript /usr/local/lib/R/site-library/swedishbirdrecoveries/exec/update_data.R

docker restart shiny

cron jobs and cron status

The root-user runs the following script at 04:00 (se su crontab -l)

  1. /home/ingierli/repo/swedishbirdrecoveries/docker-compose/bin/refresh-swedishbirdrecoveries.sh
  2. creates the log : refresh-swedishbirdrecoveries.log

So a 'smell' is: if you cannot find a log refresh-swedishbirdrecoveries.log with a datestamp from today, then the script did not run for some reason ....

the csv-file fetched, stored in the shiny-container

Check the datastamp on the file /tmp/recoveries.csv

$ docker exec -it shiny bash
root@3c82e89e4ebf:/# ls -ali /tmp
total 76864
1211160 drwxrwxrwt 1 root  root      4096 Apr 15 07:44 .
1211267 drwxr-xr-x 1 root  root      4096 Apr  7 15:55 ..
1593422 -rw-r--r-- 1 root  root  78682933 Apr 15 02:00 recoveries.csv
1593423 drwx------ 2 shiny shiny     4096 Apr 15 07:44 RtmpcbUkh5
1593429 drwx------ 2 shiny shiny     4096 Apr 14 15:06 Rtmpj6AJ3H
1593511 drwx------ 2 shiny shiny     4096 Apr 14 15:13 RtmpsGVOx0
root@3c82e89e4ebf:/# 

Common error

Error with the -> Running the refresh-swedishbirdrecoveries.sh-script

To try out the bundled shiny web application examples:
runShinyApp()
    
Error: The dbplyr package is required to communicate with database backends.
Backtrace:
    █
 1. └─swedishbirdrecoveries::update_data()
 2.   └─dplyr::src_sqlite(BIRDS_DB)
 3.     └─dplyr::check_dbplyr()
 4.       └─dplyr:::check_pkg(...)
 5.         └─dplyr:::glubort(...)
Execution halted
shiny

hot fix for the update script

The update_data.R is dependent on the dbplyr-package , which is not installed

  1. docker exec -it shiny bash
  2. R
  3. > install.packages("dbplyr")
  4. q();
  5. Rscript /usr/local/lib/R/site-library/swedishbirdrecoveries/exec/update_data.R
  6. exit (exit the container)
  7. docker restart shiny

after running step 5, should give this log

Last update was2017-11-13
Update needed, getting remote data...
Downloading updated dataset from http://fagel3.nrm.se/fagel/aterfynd/SQLDataExport.csv into /tmp/recoveries.csv
trying URL 'http://fagel3.nrm.se/fagel/aterfynd/SQLDataExport.csv'
Content type 'text/csv' length 78682933 bytes (75.0 MB)
==================================================
downloaded 75.0 MB

Warning: 2 parsing failures.
  row col   expected actual                  file
17461 FKD an integer   REL- '/tmp/recoveries.csv'
17462 FKD an integer   REL- '/tmp/recoveries.csv'

Parsed with column specification:
cols(
  colname = col_character(),
  desc_swe = col_character(),
  desc_eng = col_character()
)
Logging update with timestamp
Done updating/usr/local/lib/R/site-library/swedishbirdrecoveries/extdata/sbr.db
Warning message:
Missing values are always removed in SQL.
Use `MAX(x, na.rm = TRUE)` to silence this warning
This warning is displayed only once per session.

System logs

  1. ll /var/log
  2. less /var/log/syslog : [Shift]+[g] -> to the end of the log
  3. tail -f /var/log/syslog : f for follow

Viewing logs with dmesg

dmesg less

space

  1. df -h
  2. df -h /boot