Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

[WIP] added some hints for the troubleshooting; fixed sleep instructions #119

Merged
merged 9 commits into from
Sep 8, 2018
37 changes: 12 additions & 25 deletions DEPLOYMENT_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,17 @@ Welcome to HospitalRun Deployment Documentation. You can log issues, comments or
Here are some configuration scripts that have been used in designing this application. It is important you know exactly what they do, so you can manipulate your configuration or scale them as you desire.

* docker-compose.yml

* config-example.js

* Dockerfile

* utils/elasticsearch.sh

* nginx/conf/certbot-auto

* nginx/conf/*.tmpl, nginx/conf/*.conf

* nginx/conf/entrypoint.sh

* nginx/Dockerfile

* logstash/pipeline/logstash.conf

* logstash/Dockerfile

* data

* conf/initcouch.sh

* conf/entrypoint.sh

# **Deploying HospitalRun to a Production Environment**
Expand All @@ -55,29 +43,32 @@ Here are some configuration scripts that have been used in designing this applic
Follow these five easy steps to get HospitalRun up and running

1. Clone the repository `git clone [email protected]:HospitalRun/hospitalrun-server.git`.

2. Run `cd hospitalrun-server`. This should take you into the `hospitalrun-server` root folder
3. From this location, edit the `docker-compose.yml` file.
To use automatic SSL cert generation, edit the `DOMAIN_NAME` argument and replace `www.example.com` as shown in the image below with the publicly accessible domain name that HospitalRun will run on.
To instead use your own SSL cert, change the `SSL_TYPE` argument to `self` and place your certificate files at `data/nginx/cert/ssl.crt` and `data/nginx/cert/ssl.key`. You will need to create a `data/nginx/cert` path from the root folder if you haven't run the server yet.
![screenshot](screenshot.png)
4. Save the file and run `docker-compose up --build -d`. You should wait for some ten minutes or less for your environment to be up and running. Deployment speed will vary based on your internet connection speed and the quality of your infrastructure
5. Go to [http://localhost/](http://localhost/) in a browser and login with username ```hradmin``` and password ```test```

3. From this location, edit the `docker-compose.yml` file.
## Troubleshooting

To use automatic SSL cert generation, edit the `DOMAIN_NAME` argument and replace `www.example.com` as shown in the image below with the publicly accessible domain name that HospitalRun will run on.
### Check which containers run and which do not

To instead use your own SSL cert, change the `SSL_TYPE` argument to `self` and place your certificate files at `data/nginx/cert/ssl.crt` and `data/nginx/cert/ssl.key`. You will need to create a `data/nginx/cert` path from the root folder if you haven't run the server yet.
Run `docker-compose ps`. Note the `State` column of the command's output.

4. Save the file and run `docker-compose up --build -d`. You should wait for some ten minutes or less for your environment to be up and running. Deployment speed will vary based on your internet connection speed and the quality of your infrastructure
### Error starting userland proxy: Bind for 0.0.0.0:80: unexpected error Permission denied'

5. Go to [http://localhost/](http://localhost/) in a browser and login with username ```hradmin``` and password ```test```
or something similar: the port `80` is in use already. Either find which application uses that and free the port
or edit the `docker-compose.yml` and change the `"80:80"` into `"<another port which is free>:80"`.

![screenshot](screenshot.png)

# **The Data Folder**

This folder contains all the data needed to be available should the containers be shutdown, or restarted for any reason. It should contain after startup, the following:

1. Nginx folder, and Let's Encrypt certificates

2. CouchDB Data

3. Elasticsearch Data

If you delete this folder, you WILL lose all your data and installed SSL certificate
Expand All @@ -87,13 +78,9 @@ If you delete this folder, you WILL lose all your data and installed SSL certifi
**List of Containers:**

1. Nginx - WebServer

2. HospitalRun - Node.JS App Server

3. Logstash - Log Streaming Application

4. Elasticsearch - For Search

5. CouchDB - NoSQL Data Store

**Nginx**
Expand Down
10 changes: 7 additions & 3 deletions conf/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#!/usr/bin/env bash
# It will generally take about 40 seconds for elasticsearch and couchdb to be ready to receive connections
echo 'Scheduling setup scripts to run in 40 seconds...'
sleep 40 && /usr/src/app/conf/initcouch.sh 2>&1 && /usr/src/app/utils/elasticsearch.sh couchadmin test 2>&1 &
sleep 40
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, for instance, they try to postpone the script execution, but it doesn't work. Without && it works as expected and really stops the script from the execution. I believe that was the expected behavior. Opinions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your change is correct. Can we remove the part where it runs the scripts the second time? Is it possible they just included the second one because the first one always failed because it wasn't actually waiting the 40 seconds like it was supposed to?

/usr/src/app/conf/initcouch.sh 2>&1 && /usr/src/app/utils/elasticsearch.sh couchadmin test 2>&1 &

echo 'Scheduling setup scripts to run in 120 seconds...'
sleep 120 && /usr/src/app/conf/initcouch.sh 2>&1 && /usr/src/app/utils/elasticsearch.sh couchadmin test 2>&1 &
npm start
sleep 120
/usr/src/app/conf/initcouch.sh 2>&1 && /usr/src/app/utils/elasticsearch.sh couchadmin test 2>&1 &

npm start