Search code examples
couchdbubuntu-14.04cloud9-ide

How to [start|stop|restart] couchdb in cloud9?


I'm running ubuntu 14.04 and I just want to restart (stop and start) couchDB, which is running on cloud 9. I tried these but none of them seems to work:

1.

ps -U couchdb -o pid= | xargs kill -9

2.

sudo couchdb stop

3.

curl -X POST http://[username]:[password]@127.0.0.1:5984/_restart -H"Content-Type: application/json"

Solution

  • Starting the couchdb the way the Cloud9 doc says will allow a simple Control + C to close it:

    sudo mkdir -p /var/run/couchdb
    sudo chown couchdb:couchdb /var/run/couchdb 
    sudo su couchdb -c /usr/bin/couchdb
    

    enter image description here

    However is that's not what you want you can always find the PID and kill it:

    mikeumus@couchdb:~/workspace (master) $ pstree -ap|grep couchdb
    
        |       |-grep,9050 --color=auto couchdb
                  `-sudo,9018 su couchdb -c /usr/bin/couchdb
                      `-su,9019 couchdb -c /usr/bin/couchdb
                          `-beam.smp,9020 -Bd -K true -A 4 -- -root /usr/lib/erlang -progname erl -- -home /var/lib/couchdb ---noshe
    
    mikeumus@couchdb:~/workspace (master) $ sudo kill -- -9018
    
    mikeumus@couchdb:~/workspace (master) $ pstree -ap|grep couchdb
          |       |-grep,9071 --color=auto couchdb
    

    enter image description here

    Don't mind the color process still running, the couchdb process is now off. If you want to find and kill the couchdb in a single command, try:

    kill $(ps aux | grep '[c]ouchdb' | awk '{print $2}')

    Explained in this Stack Overflow Answer: https://stackoverflow.com/a/3510850/1762493