Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: database error when set GTFS_URL to oba_app #89

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
image:
name: Test Docker Image
name: Build Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -25,7 +25,7 @@ jobs:
run: docker buildx build --load -t oba-image:latest ./oba

services:
name: Test Services
name: Services with Bundler
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -35,7 +35,7 @@ jobs:
run: docker-compose up -d

- name: Wait for services to be up
run: sleep 5
run: sleep 30

- name: Test the services
run: |
Expand All @@ -45,3 +45,26 @@ jobs:
- name: Docker Compose down
if: always()
run: docker-compose down

services_standalone:
name: Services standalone
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Docker Compose up
run: docker-compose -f docker-compose.standalone.yml up -d

- name: Wait for services to be up
# leave time to download and process the GTFS data
run: sleep 60

- name: Test the services
run: |
chmod +x ./bin/validate.sh
./bin/validate.sh

- name: Docker Compose down
if: always()
run: docker-compose down
2 changes: 1 addition & 1 deletion bin/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ else
fi

output=$(curl -s "http://localhost:8080/onebusaway-api-webapp/api/where/routes-for-agency/unitrans.json?key=test" | jq '.data.list | length')
if [[ $output -gt 20 ]]; then
if [[ $output -gt 10 ]]; then
echo "routes-for-agency/unitrans.json endpoint works."
else
echo "Error: routes-for-agency/unitrans.json is not working: $output"
Expand Down
41 changes: 41 additions & 0 deletions docker-compose.standalone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: "3"

services:
oba_database:
image: mysql:8.3
container_name: oba_database
environment:
MYSQL_ROOT_PASSWORD: Ins3cure!
MYSQL_DATABASE: oba_database
MYSQL_USER: oba_user
MYSQL_PASSWORD: oba_password
ports:
- "3306:3306"
volumes:
- type: volume
source: mysql-data
target: /var/lib/mysql
restart: always

oba_app:
container_name: oba_app
depends_on:
- oba_database
build:
context: ./oba
environment:
- JDBC_URL=jdbc:mysql://oba_database:3306/oba_database
- JDBC_USER=oba_user
- JDBC_PASSWORD=oba_password
- TEST_API_KEY=test # For test only, remove in production
- TZ=America/New_York
- GTFS_URL=https://unitrans.ucdavis.edu/media/gtfs/Unitrans_GTFS.zip

ports:
# Access the webapp on your host machine at a path like
# http://localhost:8080/onebusaway-api-webapp/api/where/agency/${YOUR_AGENCY}.json?key=TEST
- "8080:8080"
# restart: always

volumes:
mysql-data:
4 changes: 4 additions & 0 deletions oba/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ RUN apt-get update && apt-get install -y \
tzdata \
unzip \
xmlstarlet \
python3-pip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN pip install supervisord-dependent-startup
RUN apt remove -y python3-pip

# Set the configured time zone
RUN ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && dpkg-reconfigure -f noninteractive tzdata

Expand Down
35 changes: 33 additions & 2 deletions oba/supervisord.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)

[supervisord]
logfile=/tmp/supervisord.log
loglevel=info
pidfile=/var/run/supervisord.pid
nodaemon=false
minfds=1024
minprocs=200

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock

[eventlistener:dependentstartup]
command=python3 -m supervisord_dependent_startup
autostart=true
autorestart=unexpected
startretries=0
exitcodes=0,3
events=PROCESS_STATE

[include]
files = /etc/supervisord.d/*.ini

[program:start]
command=/oba/bootstrap.sh
autostart=true
autostart=false
dependent_startup=true
autorestart=false
startsecs=0
startretries=0
Expand All @@ -12,7 +41,9 @@ stderr_logfile_maxbytes = 0
[program:tomcat]
user=oba_user
command=catalina.sh run
autostart=true
autostart=false
dependent_startup=true
dependent_startup_wait_for=start:exited
autorestart=true
depends_on=start
stdout_logfile=/dev/stdout
Expand Down
Loading