You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Bogdan Andu <bo...@gmail.com> on 2016/10/12 10:14:10 UTC

CouchDB 2.0 start/stop dilemma

Hi,

I see Couch 2.0 comes with a free style start / stop mechanism
and the user is encouraged to use runit or whatever mechanism
he already has on his system.

I do not want to use runit when I have modern systems like centos 7 or f
edora 24 server editions that have systemd to start/stop couchdb 2.0 using
a command like this:
$ sudo systemctl status couchdb20

Couch 2.0 does not make use of a pid file anymore .
A pid file is usefull even for systemd-managed services

Anyway I wrote a simple couchdb20.service unit file in systemd for this
purpose.

the status shows:
$ sudo systemctl status couchdb20
● couchdb20.service - Apache CouchDB Server 2.0
   Loaded: loaded (/usr/lib/systemd/system/couchdb20.service; disabled;
vendor preset: disabled)
   Active: active (running) since Wed 2016-10-12 12:24:20 EEST; 37min ago
  Process: 7950 ExecStart=/home/andu/couchdb2.0/bin/couchdb (code=exited,
status=0/SUCCESS)
 Main PID: 7956 (beam.smp)
    Tasks: 28 (limit: 512)
   CGroup: /system.slice/couchdb20.service
           ├─7956 /home/andu/couchdb2.0/bin/../erts-7.3.1/bin/beam.smp -K
true -A 16 -Bd -- -root /home/andu/couchdb2.0/bin/.. -progname couchdb --
-home /var/couchdb -- -boot /home/andu/couchdb2.0/bin/../releas
           ├─7982 sh -s disksup
           ├─7984
/home/andu/couchdb2.0/bin/../lib/os_mon-2.4/priv/bin/memsup
           ├─7985
/home/andu/couchdb2.0/bin/../lib/os_mon-2.4/priv/bin/cpu_sup
           ├─7986 inet_gethost 4
           └─7987 inet_gethost 4

Oct 12 12:24:20 nosql systemd[1]: Starting Apache CouchDB Server 2.0...
Oct 12 12:24:20 nosql systemd[1]: Started Apache CouchDB Server 2.0.

The script appears to work correctly.
All processes a cleanly-shutdown when stopped.

Do you think this is a sane approach to manage couch 2.0 ?

/Bogdan

Re: CouchDB 2.0 start/stop dilemma

Posted by Bogdan Andu <bo...@gmail.com>.
I see this topic does not appears important for community
but for me is important, and I want to share my solution to this
problem.

Maybe somebody will benefit from this.

First, I created a service unit in systemd:
$ cat /usr/lib/systemd/system/couchdb20.service
[Unit]
Description=Apache CouchDB Server 2.0
After=network.target

[Service]
User=_couchdb
Type=forking
Environment="HOME=/var/couchdb"
ExecStart="/home/andu/couchdb2.0/bin/couchdb"
#ExecReload=
ExecStop=/bin/kill -TERM $MAINPID

[Install]
WantedBy=multi-user.target

But this didn't start the server as expected because of
start script of couchdb: home/andu/couchdb2.0/bin/couchdb

I had to make minor modifications to this to work with systemd, namely:

$ cat /home/andu/couchdb2.0/bin/couchdb
#!/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.

COUCHDB_BIN_DIR=$(cd "${0%/*}" && pwd)
ERTS_BIN_DIR=$COUCHDB_BIN_DIR/../
cd "$COUCHDB_BIN_DIR/../"

export ROOTDIR=${ERTS_BIN_DIR%/*}

START_ERL=`cat "$ROOTDIR/releases/start_erl.data"`
ERTS_VSN=${START_ERL% *}
APP_VSN=${START_ERL#* }

export BINDIR="$ROOTDIR/erts-$ERTS_VSN/bin"
export EMU=beam
export PROGNAME=`echo $0 | sed 's/.*\///'`

exec "$BINDIR/erlexec" -boot "$ROOTDIR/releases/$APP_VSN/couchdb" \
     -args_file "$ROOTDIR/etc/vm.args" \
     -config "$ROOTDIR/releases/$APP_VSN/sys.config" &

exit 0

Without these modifications systemd cannot handle the Type=forking
correctly,
so the server cannot start.

Now one can start and stop the server with:
$ sudo systemctl start couchdb20
$ sudo systemctl stop couchdb20

or see the status:

$ sudo systemctl status couchdb20

/Bogdan

On Wed, Oct 12, 2016 at 1:14 PM, Bogdan Andu <bo...@gmail.com> wrote:

> Hi,
>
> I see Couch 2.0 comes with a free style start / stop mechanism
> and the user is encouraged to use runit or whatever mechanism
> he already has on his system.
>
> I do not want to use runit when I have modern systems like centos 7 or f
> edora 24 server editions that have systemd to start/stop couchdb 2.0 using
> a command like this:
> $ sudo systemctl status couchdb20
>
> Couch 2.0 does not make use of a pid file anymore .
> A pid file is usefull even for systemd-managed services
>
> Anyway I wrote a simple couchdb20.service unit file in systemd for this
> purpose.
>
> the status shows:
> $ sudo systemctl status couchdb20
> ● couchdb20.service - Apache CouchDB Server 2.0
>    Loaded: loaded (/usr/lib/systemd/system/couchdb20.service; disabled;
> vendor preset: disabled)
>    Active: active (running) since Wed 2016-10-12 12:24:20 EEST; 37min ago
>   Process: 7950 ExecStart=/home/andu/couchdb2.0/bin/couchdb (code=exited,
> status=0/SUCCESS)
>  Main PID: 7956 (beam.smp)
>     Tasks: 28 (limit: 512)
>    CGroup: /system.slice/couchdb20.service
>            ├─7956 /home/andu/couchdb2.0/bin/../erts-7.3.1/bin/beam.smp -K
> true -A 16 -Bd -- -root /home/andu/couchdb2.0/bin/.. -progname couchdb --
> -home /var/couchdb -- -boot /home/andu/couchdb2.0/bin/../releas
>            ├─7982 sh -s disksup
>            ├─7984 /home/andu/couchdb2.0/bin/../
> lib/os_mon-2.4/priv/bin/memsup
>            ├─7985 /home/andu/couchdb2.0/bin/../
> lib/os_mon-2.4/priv/bin/cpu_sup
>            ├─7986 inet_gethost 4
>            └─7987 inet_gethost 4
>
> Oct 12 12:24:20 nosql systemd[1]: Starting Apache CouchDB Server 2.0...
> Oct 12 12:24:20 nosql systemd[1]: Started Apache CouchDB Server 2.0.
>
> The script appears to work correctly.
> All processes a cleanly-shutdown when stopped.
>
> Do you think this is a sane approach to manage couch 2.0 ?
>
> /Bogdan
>

Re: View returning errors

Posted by Andy Wenk <an...@apache.org>.
Hey Karl,

I believe this is uncool and annoying. But you are writing, that you are using CouchDB 1.3, what is a very old version. I am not sure if anyone here can reproduce that error. So I know this will not solve your problem, but are you able to upgrade to a newer version? There is CouchDB 1.6.1 within the 1x branch and recently CouchDB 2.0 with all the new hot stuff …

If someone want’s to dive deeper into this issue, the Erlang version you are using will be important. If you have other system or environment info, please provide them also.

All the best 

Andy

--
Andy Wenk
RockIt!

Hamburg / Germany

GPG public key: https://pgp.mit.edu/pks/lookup?op=get&search=0x4F1D0C59BC90917D

> On 12 Oct 2016, at 22:01, Karl Helmer <he...@nmr.mgh.harvard.edu> wrote:
> 
> I'm running an instance of Couchdb 1.3 on a CentOS VM.  All of the views I
> have written for a certain db are now returning an error, previously they
> were all working.  All the views return a "noproc" error and there is a
> variety of gen_server, and get_state errors
> 
> An example log report:
> [Wed, 12 Oct 2016 18:00:37 GMT] [error] [<0.963.536>] Uncaught error in
> HTTP request: {exit,
>                                                       {noproc,
>                                                        {gen_server,call,
>                                                         [<0.14655.0>,
>                                                          {get_state,25695},
>                                                          infinity]}}}
> [Wed, 12 Oct 2016 18:00:37 GMT] [info] [<0.963.536>] Stacktrace:
> [{io_lib_pretty,cind_tag_tuple,7},
>                                  {io_lib_pretty,while_fail,3},
>                                  {io_lib_pretty,print,6},
>                                  {io_lib_format,build,3},
>                                  {io_lib_format,build,3},
>                                  {io_lib_format,build,3},
>                                  {io_lib_format,build,3},
>                                  {io_lib_format,build,3}]
> [Wed, 12 Oct 2016 18:00:37 GMT] [info] [<0.963.536>] 172.20.9.25 - - GET
> /to_record_mri/_design/record/_view/by_no_recorded_datetime?limit=11 500
> 
> I also get an error when I try to compact the view:
> "The view could not be compacted. {gen_server,call,[<0.14655.0>compact]}"
> 
> 
> However, if I open the code for one of the views that is returning an
> error and save it under a new name, then *all* of the views in that design
> document now work. But if I then delete that new duplicate view, all the
> design doc views revert back to an error
> 
> thanks,
> Karl
> 
> 
> -- 
> Karl Helmer, PhD
> Athinoula A Martinos Center
> for Biomedical Imaging
> Massachusetts General Hospital
> 149 - 13th St Room 2301
> Charlestown, MA 02129
> (p) 617.726.8636
> (f) 617.726.7422
> helmer@nmr.mgh.harvard.edu
> 
> 
> 
> 
> 
> The information in this e-mail is intended only for the person to whom it is
> addressed. If you believe this e-mail was sent to you in error and the e-mail
> contains patient information, please contact the Partners Compliance HelpLine at
> http://www.partners.org/complianceline . If the e-mail was sent to you in error
> but does not contain patient information, please contact the sender and properly
> dispose of the e-mail.
> 


View returning errors

Posted by Karl Helmer <he...@nmr.mgh.harvard.edu>.
I'm running an instance of Couchdb 1.3 on a CentOS VM.  All of the views I
have written for a certain db are now returning an error, previously they
were all working.  All the views return a "noproc" error and there is a
variety of gen_server, and get_state errors

An example log report:
[Wed, 12 Oct 2016 18:00:37 GMT] [error] [<0.963.536>] Uncaught error in
HTTP request: {exit,
                                                       {noproc,
                                                        {gen_server,call,
                                                         [<0.14655.0>,
                                                          {get_state,25695},
                                                          infinity]}}}
[Wed, 12 Oct 2016 18:00:37 GMT] [info] [<0.963.536>] Stacktrace:
[{io_lib_pretty,cind_tag_tuple,7},
                                  {io_lib_pretty,while_fail,3},
                                  {io_lib_pretty,print,6},
                                  {io_lib_format,build,3},
                                  {io_lib_format,build,3},
                                  {io_lib_format,build,3},
                                  {io_lib_format,build,3},
                                  {io_lib_format,build,3}]
[Wed, 12 Oct 2016 18:00:37 GMT] [info] [<0.963.536>] 172.20.9.25 - - GET
/to_record_mri/_design/record/_view/by_no_recorded_datetime?limit=11 500

I also get an error when I try to compact the view:
"The view could not be compacted. {gen_server,call,[<0.14655.0>compact]}"


However, if I open the code for one of the views that is returning an
error and save it under a new name, then *all* of the views in that design
document now work. But if I then delete that new duplicate view, all the
design doc views revert back to an error

thanks,
Karl


-- 
Karl Helmer, PhD
Athinoula A Martinos Center
for Biomedical Imaging
Massachusetts General Hospital
149 - 13th St Room 2301
Charlestown, MA 02129
(p) 617.726.8636
(f) 617.726.7422
helmer@nmr.mgh.harvard.edu





The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.