diff --git a/Dockerfile b/Dockerfile index f71d82f..b0ecf4d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,5 +5,5 @@ COPY --chown=node:node . . RUN npm install EXPOSE 3323 -HEALTHCHECK --interval=30s --start-period=15s --timeout=10m --retries=10 CMD wget --no-verbose --tries=1 --spider http://${SERVER_HOST}:${SERVER_PORT}/health || exit 1 -CMD npm run dev \ No newline at end of file +HEALTHCHECK --interval=30s --start-period=15s --timeout=10m --retries=10 CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:${SERVER_PORT:-3323}/health || exit 1 +CMD npm run dev diff --git a/Dockerfile.dev b/Dockerfile.dev index bca6f12..afdddeb 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -6,5 +6,5 @@ RUN npm install EXPOSE 3323 EXPOSE 3324 -HEALTHCHECK --interval=30s --start-period=15s --timeout=10m --retries=10 CMD wget --no-verbose --tries=1 --spider http://${SERVER_HOST}:${SERVER_PORT}/health || exit 1 -CMD ./dockerRunnerDev.sh \ No newline at end of file +HEALTHCHECK --interval=30s --start-period=15s --timeout=10m --retries=10 CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:${SERVER_PORT:-3323}/health || exit 1 +CMD ./dockerRunnerDev.sh diff --git a/README.md b/README.md index bdf2e25..a97ed4b 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Following are a list of modifiable paths: | URI Name | Default | Description | | --------------- | ------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------- | | SERVER_PORT | 3323 | The port to run the server on. | -| SERVER_HOST | `127.0.0.1` | The hostname of the server. | +| SERVER_HOST | `0.0.0.0` | The hostname of the server. Docker deployments use `0.0.0.0`; use `127.0.0.1` only for a host-local process. | | SPL_ZIP_PATH | /src/spl/TESTDATA_rems_document_and_rems_indexing_spl_files.zip | the path to the spl zip | | REMS_ADMIN_1_CDS_URL | http://localhost:8090/ | the CDS base url for the first rems admin | | REMS_ADMIN_1_FHIR_URL | http://localhost:8090/ | the FHIR base url for the first rems admin | diff --git a/dockerRunnerDev.sh b/dockerRunnerDev.sh index 6615a56..9d922fb 100755 --- a/dockerRunnerDev.sh +++ b/dockerRunnerDev.sh @@ -1,9 +1,9 @@ #!/bin/sh # Handle closing application on signal interrupt (ctrl + c) -trap 'kill $CONTINUOUS_INSTALL_PID $SERVER_PID; gradle --stop; exit' INT +trap 'kill $CONTINUOUS_INSTALL_PID $SERVER_PID 2>/dev/null; exit' INT TERM -mkdir logs +mkdir -p logs # Reset log file content for new application boot echo "*** Logs for continuous installer ***" > ./logs/installer.log echo "*** Logs for 'npm run start' ***" > ./logs/runner.log @@ -13,23 +13,31 @@ echo "starting application in watch mode..." # Start the continious build listener process echo "starting continuous installer..." -npm install +if [ ! -d node_modules ]; then + npm install | tee ./logs/installer.log +fi -( package_modify_time=$(stat -c %Y package.json) -package_lock_modify_time=$(stat -c %Y package-lock.json) +( file_hash() { + cksum "$1" 2>/dev/null || echo "missing $1" +} + +package_hash=$(file_hash package.json) +package_lock_hash=$(file_hash package-lock.json) while sleep 1 do - new_package_modify_time=$(stat -c %Y package.json) - new_package_lock_modify_time=$(stat -c %Y package-lock.json) + new_package_hash=$(file_hash package.json) + new_package_lock_hash=$(file_hash package-lock.json) - if [[ "$package_modify_time" != "$new_package_modify_time" ]] || [[ "$package_lock_modify_time" != "$new_package_lock_modify_time" ]] + if [ "$package_hash" != "$new_package_hash" ] || [ "$package_lock_hash" != "$new_package_lock_hash" ] then echo "running npm install..." npm install | tee ./logs/installer.log + new_package_hash=$(file_hash package.json) + new_package_lock_hash=$(file_hash package-lock.json) fi - package_modify_time=$new_package_modify_time - package_lock_modify_time=$new_package_lock_modify_time + package_hash=$new_package_hash + package_lock_hash=$new_package_lock_hash done ) & CONTINUOUS_INSTALL_PID=$! @@ -40,5 +48,3 @@ done ) & CONTINUOUS_INSTALL_PID=$! wait $CONTINUOUS_INSTALL_PID $SERVER_PID EXIT_CODE=$? echo "application exited with exit code $EXIT_CODE..." - - diff --git a/src/data.ts b/src/data.ts index 97d8d8f..93f7176 100644 --- a/src/data.ts +++ b/src/data.ts @@ -51,5 +51,14 @@ export const medications : Medication[] = [ rems_fhir_base_url: env.get('REMS_ADMIN_1_FHIR_URL').asString(), rems_approval_date: "20240906", rems_modification_date: "20240906" + }, { + brand_name: "Pexidartinib Hydrochloride", + generic_name: "PEXIDARTINIB HYDROCHLORIDE", + package_ndc: "99999-407-20", + rems_administrator: "REMS Prototype Admin 2", + rems_cds_endpoint: env.get('REMS_ADMIN_2_CDS_URL').asString(), + rems_fhir_base_url: env.get('REMS_ADMIN_2_FHIR_URL').asString(), + rems_approval_date: "20240906", + rems_modification_date: "20240906" } -]; \ No newline at end of file +]; diff --git a/src/server.ts b/src/server.ts index 88a154a..8b3b82d 100644 --- a/src/server.ts +++ b/src/server.ts @@ -10,8 +10,8 @@ import * as env from 'env-var'; import { Medication, medications } from './data'; import { Response, Meta, Results, ErrorResponse } from './response'; -const hostname = env.get('SERVER_HOST').asString(); -const port = env.get('SERVER_PORT').asInt(); +const hostname = env.get('SERVER_HOST').default('0.0.0.0').asString(); +const port = env.get('SERVER_PORT').default('3323').asPortNumber(); const spl_zip_path = env.get('SPL_ZIP_PATH').asString()!; const server = createServer((req: IncomingMessage, res: ServerResponse) => { @@ -141,4 +141,4 @@ const server = createServer((req: IncomingMessage, res: ServerResponse) => { server.listen(port, hostname, () => { console.log(`Server running at http://${hostname}:${port}/`); -}); \ No newline at end of file +});