Bug 234100 - databases/couchdb2 service keeping stdout open
Summary: databases/couchdb2 service keeping stdout open
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Dave Cottlehuber
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-17 15:49 UTC by Reshad Patuck
Modified: 2018-12-21 20:53 UTC (History)
3 users (show)

See Also:


Attachments
suppress stdin when running as daemon (703 bytes, patch)
2018-12-19 09:42 UTC, Dave Cottlehuber
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Reshad Patuck 2018-12-17 15:49:46 UTC
Hey, I noticed running service couchdb2 start via ssh keeps the ssh connection open, even after it is done.

This is not a problem when running without a parent shell.

Test case:

on a server make this script:
```
#!/bin/sh
echo "Start"
service couchdb2 restart
echo "Done"
```

now ssh to the server and run the script (without a shell)
```
ssh myserver.com sh /path/to/script.sh
```

The script will run and both Start and Done will be printed but the ssh will remain open even though the script is done.

Changing the script to pipe the service command to /dev/null fixed this.
Comment 1 Reshad Patuck 2018-12-17 15:56:24 UTC
More simply

This command exits:
ssh root@10.10.10.10 "service couchdb2 restart > /dev/null"

This command never exits:
ssh root@10.10.30.20 "service couchdb2 restart"

Both of them restart the server successfully
Comment 2 Dave Cottlehuber freebsd_committer 2018-12-17 19:23:57 UTC
Hmm what’s in your vm.args and your [log] section of local.ini? btw I don’t have this on my end https://hackmd.io/s/Byp9sBQA7 specifically notes the noinput
Comment 3 Dave Cottlehuber freebsd_committer 2018-12-17 21:38:05 UTC
Thanks for the bug report Reshad, I'm back at a keyboard and can replicate this
too. A cleaner solution might be to add `-detached` to your vm.args, it seems
fine here.

Let me know how that works for you.
Comment 4 Reshad Patuck 2018-12-18 04:11:06 UTC
(In reply to Dave Cottlehuber from comment #3)

Hey Dave,

adding `-detached` to vm.args does seem to solve the problem.

Should we add this to the port as a default??
Comment 5 Dave Cottlehuber freebsd_committer 2018-12-19 09:42:18 UTC
Created attachment 200255 [details]
suppress stdin when running as daemon

via https://github.com/skunkwerks/ports/commit/63c8ee999d3b27695d2b6e7e565be69918668fc5.diff

jrm@ can you +1 this when ready to land?
reshad this resolves new installs but I can't do anything to modify existing/deployed configs. I think this is sufficient though.
Comment 6 Joseph Mingrone freebsd_committer 2018-12-19 12:04:10 UTC
Approved.
Comment 7 Reshad Patuck 2018-12-19 15:19:12 UTC
(In reply to Dave Cottlehuber from comment #5)

Awesome, I've already pushed the config out to my fleet of servers.

Cheers,

Reshad
Comment 8 commit-hook freebsd_committer 2018-12-21 20:51:49 UTC
A commit references this bug:

Author: dch
Date: Fri Dec 21 20:51:19 UTC 2018
New revision: 488025
URL: https://svnweb.freebsd.org/changeset/ports/488025

Log:
  databases/couchdb2: detach stdout from daemon invocation

  When CouchDB is started whithout a parent tty, for example, via ssh,
  the daemon invocation retains a connection to stdout, thus blocking
  disconnection of the ssh command.

  The Erlang VM provides a `-detach` flag for avoiding this situation.
  Add additional notes on debugging to the config file to aid users.

  PR:		234100
  Reported by:	Reshad Patuck <reshadpatuck1@gmail.com>
  Reviewed by:	Reshad Patuck <reshadpatuck1@gmail.com>
  Approved by:	jrm (mentor)

Changes:
  head/databases/couchdb2/Makefile
  head/databases/couchdb2/files/patch-rel_overlay_etc_vm.args
Comment 9 Dave Cottlehuber freebsd_committer 2018-12-21 20:53:37 UTC
closed in r488025. Thanks again Reshad!