Skip to content
Open
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
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
4 changes: 2 additions & 2 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
30 changes: 18 additions & 12 deletions dockerRunnerDev.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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=$!

Expand All @@ -40,5 +48,3 @@ done ) & CONTINUOUS_INSTALL_PID=$!
wait $CONTINUOUS_INSTALL_PID $SERVER_PID
EXIT_CODE=$?
echo "application exited with exit code $EXIT_CODE..."


11 changes: 10 additions & 1 deletion src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
];
];
6 changes: 3 additions & 3 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -141,4 +141,4 @@ const server = createServer((req: IncomingMessage, res: ServerResponse) => {

server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
});
Loading