I want to create a cloud9 automated setup script for an application, which uses couchdb for database. Part of the script, is the setup of the application database, which needs couchdb running, in order to function properly.
The problem is that the only available solution about couchdb on cloud9 helps you instantiate couchdb as a foreground procedure. So if you want to test the correctness of the instantiation, or execute any other command you need to open a second terminal tab as documented in the above solution, but this is not functional in my case.
So how do I make couchdb run in the background?
Ok CouchDB can be executed in the background on Cloud9, if you pass the parameter
-b
to the executable, or by reconfiguring the executable to run in the background by default. But if you try to run couchdb like this, you will run into unexisting log files and permission errors when couchdb tries to create them.So following the bellow steps will get couchdb up and running smoothly.
1. Create log files (and give proper permissions to couchdb user)
2. Create CouchDB pid storage dir
3.Reconfigure Executable
Change
STDERR_FILE:couchdb.stderr
withSTDERR_FILE:/var/log/couchdb/couchdb.stderr
And
STDERR_FILE:couchdb.stdout
withSTDERR_FILE:/var/log/couchdb/couchdb.stdout
4.Run in background
5.Test
+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 also changeBACKGROUND=false
withBACKGROUND=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
.