zulip/scripts/lib
Greg Price 2a59b2d2ac install: Work around a bug in the (our) Debian package for camo.
Before this fix, the installer has an extremely annoying bug where
when run inside a container with `lxc-attach`, when the installer
finishes, the `lxc-attach` just hangs and doesn't respond even to
C-c or C-z.  The only way to get the terminal back is to root around
from some other terminal to find the PID and kill it; then run
something like `stty sane` to fix the messed-up terminal settings
left behind.

After bisecting pieces of the install script to locate which step
was causing the issue, it comes down to the `service camo restart`.
The comment here indicates that we knew about an annoying bug here
years ago, and just swept it under the rug by skipping this step
when in Travis. >_<

The issue can be reproduced by running simply `service camo restart`
under `lxc-attach` instead of the installer; or `service camo start`,
following a `service camo stop`.  If `lxc-attach` is used to get an
interactive shell, these commands appear to work fine; but then when
that shell exits, the same hang appears.  So, when we start camo
we're evidently leaving some kind of mess that entangles the daemon
with our shell.

Looking at the camo initscript where it starts the daemon, there's
not much code, and one flag jumps out as suspicious:

  start-stop-daemon --start --quiet --pidfile $PIDFILE -bm \
    --exec $DAEMON --no-close -c nobody --test > /dev/null 2>&1 \
    || return 1
  start-stop-daemon --start --quiet --pidfile $PIDFILE -bm \
    --no-close -c nobody --exec $DAEMON -- \
    $DAEMON_ARGS >> /var/log/camo/camo.log 2>&1 \
    || return 2

What does `--no-close` do?

 -C, --no-close
     Do not close any file descriptor when forcing the daemon
     into  the  background  (since version 1.16.5).  Used for
     debugging purposes to see  the  process  output,  or  to
     redirect  file  descriptors  to  log the process output.

And in fact, looking in /proc/PID/fd while a hang is happening finds
that fd 0 on the camo daemon process, aka stdin, is connected to our
terminal.

So, stop that by denying the initscript our stdin in the first place.
This fixes the problem.

The Debian maintainer turns out to be "Zulip Debian Packaging Team",
at debian@zulip.com; so this package and its bugs are basically ours.
2018-01-22 18:55:46 -08:00
..
third deps: Change npm to yarn for reliablity, security, and speed. 2017-08-05 12:29:06 -07:00
__init__.py Factor out venv-creating code from provision.py. 2016-06-21 11:25:41 -07:00
cd_exec scripts: Add cd_exec library helper. 2017-07-21 17:28:20 -07:00
certbot-maybe-renew certbot: Use --deploy-hook to get the cert actually served. 2017-11-15 21:50:41 -08:00
check-upstart install: Add clear error message if upstart is installed on Xenial. 2016-11-29 19:16:26 -08:00
clean-emoji-cache scripts: Rearrange the arguments of `purge_unused_caches()`. 2017-09-24 04:37:31 -07:00
clean-npm-cache clean-npm-cache: Fix path to yarn in Travis CI. 2017-11-23 12:01:20 -08:00
clean-unused-caches caches: Suppress unnecessary output when cleaning caches. 2017-09-25 16:34:03 -07:00
clean-venv-cache clean-venv-cache: Fix an exception with unusual deployment dirs. 2017-10-31 00:01:09 -07:00
create-production-venv requirements: Rename requirements files. 2017-11-21 02:38:26 +05:30
create-thumbor-venv requirements: Rename requirements files. 2017-11-21 02:38:26 +05:30
create-zulip-admin Add script to create admin from CLI. 2017-09-27 20:15:41 -07:00
docker-functions.sh Fix various typos. 2017-11-09 16:26:38 +01:00
email-mirror-postfix email-mirror-postfix: Replace optparse with argparse. 2017-11-21 21:34:38 -08:00
hash_reqs.py scripts: Remove import print_function. 2017-09-29 15:43:30 -07:00
install install: Work around a bug in the (our) Debian package for camo. 2018-01-22 18:55:46 -08:00
install-node deps: Change npm to yarn for reliablity, security, and speed. 2017-08-05 12:29:06 -07:00
node_cache.py mypy: Set type parameters for IO to Any in scripts/lib/node_cache.py. 2017-11-04 19:47:44 -07:00
pythonrc.py scripts: Remove import print_function. 2017-09-29 15:43:30 -07:00
queue_workers.py scripts: Remove import print_function. 2017-09-29 15:43:30 -07:00
setup-apt-repo setup-apt-repo: Fix failure to rerun properly on provision failure. 2017-09-12 07:08:54 -07:00
setup_path_on_import.py linter: Add lint rule banning 'import os.path' 2017-09-22 10:32:21 -07:00
setup_venv.py thumbor: Add dependencies and virtualenv setup script. 2017-11-16 22:38:29 -08:00
unpack-zulip scripts: Remove import print_function. 2017-09-29 15:43:30 -07:00
upgrade-zulip refactor: Replace mkdir_p functions with Python 3 builtin. 2017-10-25 11:06:11 -07:00
upgrade-zulip-stage-2 reminder_bot: Add infra for adding reminder bot to every realm. 2018-01-19 11:33:11 -05:00
zulip_tools.py scripts: Text-wrap long lines exceeding 110. 2017-11-10 16:22:26 -08:00