10gen / mongo-orchestration

Apache License 2.0
7 stars 11 forks source link

Allow running in background from git checkout. #246

Closed p-mongo closed 5 years ago

p-mongo commented 6 years ago

Running from a git checkout (with local paths) means Python modules have local paths to them, which doesn't work too well with daemonization as part of daemonization chdirs to /.

To fix, preload the application prior to daemonization.

ShaneHarvey commented 5 years ago

I'm a bit confused by what this change actually does. Can you explain what the functional difference is with a real example?

p-mongo commented 5 years ago

As I recall running mongo-orchestration with daemonization from a git checkout did not work for me. The readme doesn't say how to run mongo-orchestration from a git checkout at all, only covering dependency installation, hence that should be addressed first I imagine.

ShaneHarvey commented 5 years ago

The readme does explain how to install MO from a git checkout:

You can also install the development version of Mongo Orchestration manually:

git clone https://github.com/10gen/mongo-orchestration.git
cd mongo-orchestration
pip install .

How are you trying to run mongo-orchestration?

p-mongo commented 5 years ago

Right, I've done those steps.

How are you trying to run mongo-orchestration?

As far as I can tell this part is not covered in the readme.

ShaneHarvey commented 5 years ago

That's also mentioned in the read me here:

mongo-orchestration start

After some debugging I think this is a manifestation of #237. This works fine for me:

git clone https://github.com/10gen/mongo-orchestration.git
cd mongo-orchestration
pip install .
mongo-orchestration start -b '127.0.0.1'

After #258 is merged the -b '127.0.0.1' workaround isn't needed anymore. So I think we can close this issue.

p-mongo commented 5 years ago
butler% git clone https://github.com/10gen/mongo-orchestration.git
cd mongo-orchestration
pip install .
mongo-orchestration start -b '127.0.0.1'
Cloning into 'mongo-orchestration'...
remote: Enumerating objects: 12, done.
remote: Counting objects: 100% (12/12), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 3754 (delta 4), reused 5 (delta 2), pack-reused 3742
Receiving objects: 100% (3754/3754), 898.88 KiB | 338.00 KiB/s, done.
Resolving deltas: 100% (2600/2600), done.
Processing /home/sandbox/1/mongo-orchestration
  Requirement already satisfied (use --upgrade to upgrade): mongo-orchestration==0.6.12.dev0 from file:///home/sandbox/1/mongo-orchestration in /home/sandbox/.local/lib/python2.7/site-packages
Requirement already satisfied: pymongo<3.6.0,>=3.0.2 in /home/sandbox/.local/lib/python2.7/site-packages (from mongo-orchestration==0.6.12.dev0)
Requirement already satisfied: bottle>=0.12.7 in /home/sandbox/.local/lib/python2.7/site-packages (from mongo-orchestration==0.6.12.dev0)
Requirement already satisfied: CherryPy<7.1,>=3.5.0 in /home/sandbox/.local/lib/python2.7/site-packages (from mongo-orchestration==0.6.12.dev0)
Requirement already satisfied: six in /usr/local/lib/python2.7/dist-packages (from CherryPy<7.1,>=3.5.0->mongo-orchestration==0.6.12.dev0)
Building wheels for collected packages: mongo-orchestration
  Running setup.py bdist_wheel for mongo-orchestration ... done
  Stored in directory: /home/sandbox/.cache/pip/wheels/70/4f/fb/84e1078df854f08c0f4acf95e3796bef24f8da6773f775e343
Successfully built mongo-orchestration
You are using pip version 9.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
zsh: command not found: mongo-orchestration

This is expected since there is no mongo-orchestration in PATH.

ShaneHarvey commented 5 years ago

This looks like https://github.com/pypa/pip/pull/4553. I did not run into this because I was using a virtualenv which automatically augments PATH appropriately. If you upgrade pip (python -m pip install --upgrade pip) you should see this warning:

$ python -m pip install --user .
Processing /Users/shane/mo-246/mongo-orchestration
...
Installing collected packages: mongo-orchestration
  The script mongo-orchestration is installed in '/Users/shane/Library/Python/2.7/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed mongo-orchestration-0.6.12.dev0

So the options are to:

  1. Add that directory to your path manually.
  2. Use a virtualenv.
  3. Use python -m mongo_orchestration.server start instead of mongo-orchestration start

(3) seems like the easiest option. Perhaps we should make it easier by allowing python -m mongo_orchestration.

p-mongo commented 5 years ago

Okay, I got m-o working with mongo-orchestration start -b 127.0.0.1.

I think it's fine for m-o instructions to specify that it is meant to run in a virtualenv from git checkout. If this isn't explicitly mentioned I personally wouldn't think that a project assumes it is run in a virtualenv.

ShaneHarvey commented 5 years ago

Added a description of this problem to the readme in this commit :

If you have installed mongo-orchestration but you're still getting
``command not found: mongo-orchestration`` this means that the script was
installed to a directory that is not on your ``PATH``. As an alternative use:

``python -m mongo_orchestration.server start``

Okay to resolve?

p-mongo commented 5 years ago

Okay thanks.