Skip to content

Commit

Permalink
write all config changes at once (#6)
Browse files Browse the repository at this point in the history
to work around problem where sometimes erlang query server is not enabled because
config file was written after couchdb had already started.
  • Loading branch information
langalex authored Mar 27, 2020
1 parent 66c00fb commit 11e2c9f
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 24 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Set up CouchDB
uses: cobot/couchdb-action@master
uses: ./
with:
couchdb version: '2.3.1'
erlang query server: true
- name: Test that CouchDB can be accessed
run: curl -sS -f http://127.0.0.1:5984/
- name: Test that system databases are there
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CouchDB GitHub Action

This [GitHub Action](https://github.com/features/actions) sets up a CouchDB database.
The Erlang query server is enabled.

# Usage

Expand All @@ -13,7 +14,6 @@ steps:
uses: "cobot/couchdb-action@master"
with:
couchdb version: '2.3.1'
erlang query server: true|false
- name: Do something
run: |
curl http://127.0.0.1:5984/
Expand Down
4 changes: 0 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ inputs:
description: 'Version of CouchDB to use.'
required: false
default: 'latest'
erlang query server:
description: 'Enable Erlang query server.'
required: false
default: true
runs:
using: 'docker'
image: 'Dockerfile'
18 changes: 1 addition & 17 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,7 @@ sh -c "docker run -d -p 5984:5984 -p 5986:5986 --tmpfs /ram_disk couchdb:$INPUT_
# CouchDB container name
export NAME=`docker ps --format "{{.Names}}" --last 1`

# Enable delayed commits for better performance
echo "Enabling delayed commits..."
docker exec $NAME mkdir -p /opt/couchdb/etc/local.d
docker exec $NAME sh -c 'echo "[couchdb]\ndelayed_commits = true" >> /opt/couchdb/etc/local.d/01-delayed-commits.ini'

echo "Setting nodelay option"
docker exec $NAME sh -c 'echo "[httpd]\nsocket_options = [{nodelay, true}]" >> /opt/couchdb/etc/local.d/02-performance.ini'

echo "Configuring CouchDB to use RAM disk"
docker exec $NAME sh -c 'echo "[couchdb]\ndatabase_dir = /ram_disk\nview_index_dir = /ram_disk" >> /opt/couchdb/etc/local.d/03-ram-disk.ini'

# Enable Erlang query server
if [ "$INPUT_ERLANG_QUERY_SERVER" = 'true' ]
then
echo "Enabling Erlang query server..."
docker exec $NAME sh -c 'echo "[native_query_servers]\nerlang = {couch_native_process, start_link, []}" >> /opt/couchdb/etc/local.d/15-erlang-query-server.ini'
fi
docker exec $NAME sh -c 'mkdir -p /opt/couchdb/etc/local.d && echo "[couchdb]\ndatabase_dir = /ram_disk\nview_index_dir = /ram_disk\ndelayed_commits = true\n[httpd]\nsocket_options = [{nodelay, true}]\n[native_query_servers]\nerlang = {couch_native_process, start_link, []}" >> /opt/couchdb/etc/local.d/01-github-action-custom.ini'

wait_for_couchdb() {
echo "Waiting for CouchDB..."
Expand Down

0 comments on commit 11e2c9f

Please sign in to comment.