Run CouchDB on the background on Cloud9

couchdb

#1

Run CouchDB in the background on Cloud9

1. Create log files (and give proper permissions to couchdb user)

sudo su couchdb -c 'touch /var/log/couchdb/couchdb.stdout'
sudo su couchdb -c 'touch /var/log/couchdb/couchdb.stderr'
sudo chown couchdb: /var/log/couchdb
sudo chmod u+w /var/log/couchdb

2. Create CouchDB pid storage dir

sudo mkdir -p /var/run/couchdb
sudo chown couchdb:couchdb /var/run/couchdb

3.Reconfigure Executable
sudo nano /usr/bin/couchdb

Change
STDERR_FILE:couchdb.stderr with STDERR_FILE:/var/log/couchdb/couchdb.stderr
And
STDERR_FILE:couchdb.stdout with STDERR_FILE:/var/log/couchdb/couchdb.stdout

4.Run in background

sudo su couchdb -c '/usr/bin/couchdb -b'

5.Test

curl http://127.0.0.1:5984

+Bonus1
If you want to run CouchDB on the background, without the -b parameter, like this:

sudo su couchdb -c /usr/bin/couchdb

then in step 3, when reconfiguring the couchdb executable, you should
change BACKGROUND=false with BACKGROUND=true

+Bonus2

bash script version: Create a .sh file, add the following commands and run it on cloud9 workspace to properly set up couchdb for background execution. After executing the script start CouchDB with sudo su couchdb -c /usr/bin/couchdb.

sudo su couchdb -c 'touch /var/log/couchdb/couchdb.stdout'
sudo su couchdb -c 'touch /var/log/couchdb/couchdb.stderr'
sudo chown couchdb: /var/log/couchdb
sudo chmod u+w /var/log/couchdb
sudo mkdir -p /var/run/couchdb
sudo chown couchdb:couchdb /var/run/couchdb
sudo sed -i 's_couchdb.stderr_/var/log/couchdb/couchdb.stderr_g' /usr/bin/couchdb
sudo sed -i 's_couchdb.stdout_/var/log/couchdb/couchdb.stdout_g' /usr/bin/couchdb
sudo sed -i 's_BACKGROUND=false_BACKGROUND=true_g' /usr/bin/couchdb