Skip to content
Permalink
Browse files
Snap improvements
* Added warning on snap remove
* data now points to SNAP_COMMON with pre-refresh hook to migrate users
  • Loading branch information
sklassen authored and wohali committed Sep 24, 2019
1 parent 43bfe76 commit 956c3068e8fa26ec3de7b29c73ac256ff6109db1
Showing 4 changed files with 64 additions and 9 deletions.
@@ -61,10 +61,34 @@ $ sudo snap restart couchdb

## Monitoring CouchDB

The logs, by default, are captured by journald. View the logs with:
The logs, by default, are captured by journald. View the logs with either command:

```bash
$ journalctl -u snap.couchdb* -f`
$ snap logs couchdb -f
$ journalctl -u snap.couchdb* -f
```

## Removing CouchDB

There are several difference between installation via 'apt' and 'snap'. One important
difference is when removing couchdb. When calling 'apt remove couchdb', the binaries
are removed but the configuration and the couch database files remain, leaving the
user to clean up any databases latter.

Calling 'snap remove couchdb' *will* remove binaries, configurations and the database.

On newer versions of snapd (snapd 2.39+) a snapshot is made of the SNAP_DATA
and SNAP_COMMON directories and this is stored (subject to disc space) for about 30 days.
On these newer version a 'snap remove' followed by a 'snap install' may restore the
database; but you are best to make your own backup before removing couchdb.
If you do not want to keep the configuration or database files you can delete the
snapshot by calling snap remove with the --purge parameter.

To remove your installation either:

```bash
$ sudo snap remove couchdb
$ sudo snap remove couchdb --purge
```

-----
@@ -89,7 +113,7 @@ couchdb-c1> apt update
couchdb-c1> snap install couchdb --edge
couchdb-c1> snap connect couchdb:mount-observe
couchdb-c1> snap connect couchdb:process-control
couchdb-c1> curl -X PUT http://localhost:5984/_node/_local/_config/httpd/bind_address -d '"0.0.0.0"'
couchdb-c1> curl -X PUT http://localhost:5984/_node/_local/_config/chttpd/bind_address -d '"0.0.0.0"'
couchdb-c1> curl -X PUT http://localhost:5984/_node/_local/_config/admins/admin -d '"Be1stDB"'
couchdb-c1> exit
```
@@ -12,13 +12,15 @@
# License for the specific language governing permissions and limitations under
# the License.

mkdir -p ${SNAP_COMMON}/data

mkdir -p ${SNAP_DATA}/etc/local.d

if [ ! -s ${SNAP_DATA}/etc/vm.args ]; then
cp ${SNAP}/opt/couchdb/etc/vm.args.dist ${SNAP_DATA}/etc/vm.args
cat ${SNAP}/opt/couchdb/etc/vm.args.dist > ${SNAP_DATA}/etc/vm.args
fi

if [ ! -s ${SNAP_DATA}/etc/local.ini ]; then
cp ${SNAP}/opt/couchdb/etc/local.ini.dist ${SNAP_DATA}/etc/local.ini
cat ${SNAP}/opt/couchdb/etc/local.ini.dist > ${SNAP_DATA}/etc/local.ini
fi

@@ -0,0 +1,22 @@
#!/bin/sh

# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

# If the data directory does not exisit in /var/couchdb/common; but does exisit in /var/couchdb/current; move it to common.

if [ ! -d ${SNAP_COMMON}/data ]; then
if [ -d ${SNAP_DATA}/data ]; then
mv ${SNAP_DATA}/data ${SNAP_COMMON}/data
fi
fi

@@ -82,9 +82,9 @@ parts:
layout:
# Database and log files are common across upgrades
$SNAP/opt/couchdb/data:
bind: $SNAP_DATA/data
bind: $SNAP_COMMON/data
$SNAP/opt/couchdb/var/log:
bind: $SNAP_DATA/log
bind: $SNAP_COMMON/log
# Local configuration files may change across upgrades
$SNAP/opt/couchdb/etc/vm.args:
bind-file: $SNAP_DATA/etc/vm.args
@@ -93,6 +93,10 @@ layout:
$SNAP/opt/couchdb/etc/local.ini:
bind-file: $SNAP_DATA/etc/local.ini
# We do not bind default.ini or default.d/ as these are intended to be immutable

environment:
COUCHDB_ARGS_FILE: ${SNAP_DATA}/etc/vm.args
ERL_FLAGS: "-couch_ini ${SNAP}/opt/couchdb/etc/default.ini ${SNAP}/opt/couchdb/etc/default.d ${SNAP_DATA}/etc/local.ini ${SNAP_DATA}/etc/local.d"

apps:
couchdb:
@@ -106,7 +110,10 @@ apps:
plugs: [network, network-bind, process-control, mount-observe]
remsh:
command: opt/couchdb/bin/remsh
plugs: [network, network-bind, process-control]
plugs: [network, network-bind]
couchup:
command: opt/couchdb/bin/couchup
plugs: [network, network-bind, process-control]
plugs: [network, network-bind]
couchjs:
command: opt/couchdb/bin/couchjs
plugs: [network, network-bind]

0 comments on commit 956c306

Please sign in to comment.