Skip to content

Commit 1231a18

Browse files
authored
Updated launch.sh to handle Mac better (#53)
Docker on Mac was having issues with mounting /tmp/, so update launch.sh to throw a warning if it is unable to mount, create, or own a folder mounted there. Also decreased delay in the handler in looking for new jobs as well as disabled watch for __pycache__ in handler start with PM2. Watch should....be disabled for local deployment and instead a development docker compose should be written, but we're keeping this set of changes to the minimum for now.
1 parent c180d71 commit 1231a18

File tree

5 files changed

+39
-5
lines changed

5 files changed

+39
-5
lines changed

docker-compose.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ services:
3131
condition: service_healthy
3232
healthcheck:
3333
test: ["CMD", "curl", "-f", "http://localhost:8082/health"]
34+
interval: 10s
35+
timeout: 10s
36+
retries: 5
37+
start_period: 30s
3438
working_dir: /app/api
3539
command:
3640
./dev.sh
@@ -61,7 +65,7 @@ services:
6165
networks:
6266
- ezbids
6367
tty: true #turn on color for bids-validator output
64-
command: pm2 start handler.js --attach --watch --ignore-watch "ui **/node_modules"
68+
command: pm2 start handler.js --attach --watch --ignore-watch "ui **/node_modules **__pycache__**"
6569

6670
ui:
6771
container_name: brainlife_ezbids-ui
@@ -70,8 +74,16 @@ services:
7074
environment:
7175
VITE_APIHOST: http://${SERVER_NAME:-localhost}:8082
7276
VITE_BRAINLIFE_AUTHENTICATION: ${BRAINLIFE_AUTHENTICATION:-false}
77+
depends_on:
78+
- api
79+
- mongodb
80+
- handler
7381
healthcheck:
7482
test: ["CMD", "curl", "-f", "http://localhost:3000"]
83+
interval: 10s
84+
timeout: 10s
85+
retries: 5
86+
start_period: 30s
7587
ports:
7688
- 3000:3000 #vite wants to be exposed on the host for HMR?
7789
networks:

handler/handler.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

handler/handler.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
const { spawn } = require('child_process');
32
import fs = require('fs');
43

@@ -40,7 +39,7 @@ function run() {
4039
}
4140
}
4241
console.log("waiting a bit before looking for more jobs");
43-
setTimeout(run, 1000*3);
42+
setTimeout(run, 1000*1);
4443
});
4544
}
4645

handler/start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# start server components
44
pm2 delete ezbids-handler
5-
pm2 start handler.js --name ezbids-handler --watch --ignore-watch="*.log test *.sh ui bin example .git .syncthing*"
5+
pm2 start handler.js --name ezbids-handler --watch --ignore-watch="*.log test *.sh ui bin example .git .syncthing* __pycache__"
66

77
pm2 delete ezbids-handler-tsc
88
pm2 start tsc.sh --name ezbids-handler-tsc

launch.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,29 @@ else
6767
mkdir -p ${EZBIDS_TMP_DIR}
6868
fi
6969

70+
# Ensure proper permissions for Docker access
71+
# Get the current user's UID and GID
72+
CURRENT_UID=$(id -u)
73+
CURRENT_GID=$(id -g)
74+
75+
# Set permissions to allow Docker access
76+
if ! chmod 770 ${EZBIDS_TMP_DIR} 2>/dev/null; then
77+
echo "Warning: Unable to set permissions on ${EZBIDS_TMP_DIR}"
78+
echo "You may need to run one of the following commands with sudo:"
79+
echo " sudo chmod 770 ${EZBIDS_TMP_DIR}"
80+
echo " sudo chown ${CURRENT_UID}:${CURRENT_GID} ${EZBIDS_TMP_DIR}"
81+
echo "Alternatively, you can set EZBIDS_TMP_DIR in your .env file to a directory you own."
82+
exit 1
83+
fi
84+
85+
if ! chown ${CURRENT_UID}:${CURRENT_GID} ${EZBIDS_TMP_DIR} 2>/dev/null; then
86+
echo "Warning: Unable to set ownership on ${EZBIDS_TMP_DIR}"
87+
echo "You may need to run:"
88+
echo " sudo chown ${CURRENT_UID}:${CURRENT_GID} ${EZBIDS_TMP_DIR}"
89+
echo "Alternatively, you can set EZBIDS_TMP_DIR in your .env file to a directory you own."
90+
exit 1
91+
fi
92+
7093
# ok docker compose is now included in docker as an option for docker
7194
if [[ $(command -v docker-compose) ]]; then
7295
# if the older version is installed use the dash

0 commit comments

Comments
 (0)