nanobox-io / nanobox-engine-python

Engine for running Python apps on Nanobox
https://nanobox.io
MIT License
12 stars 13 forks source link

Boxfile exec field isn't used at the end of nanobox run #13

Closed harobed closed 8 years ago

harobed commented 8 years ago

What I do :

$ git clone https://github.com/harobed/nanobox-python-sample.git
$ cd nanobox-python-sample
$ nanobox destroy
$ nanobox  update
$ nanobox update-images
$ nanobox run

I got :

...
PIP INSTALL --------------------------->
   You are using pip version 6.0.8, however version 7.1.2 is available.
   You should consider upgrading via the 'pip install --upgrade pip' command.
   Requirement already satisfied (use --upgrade to upgrade): flask in ./env/lib/python2.7/site-packages (from -r /opt/code/requirements.txt (line 1))
   Requirement already satisfied (use --upgrade to upgrade): Werkzeug>=0.7 in ./env/lib/python2.7/site-packages (from flask->-r /opt/code/requirements.txt (line 1))
   Requirement already satisfied (use --upgrade to upgrade): Jinja2>=2.4 in ./env/lib/python2.7/site-packages (from flask->-r /opt/code/requirements.txt (line 1))
   Requirement already satisfied (use --upgrade to upgrade): itsdangerous>=0.21 in ./env/lib/python2.7/site-packages (from flask->-r /opt/code/requirements.txt (line 1))
   Requirement already satisfied (use --upgrade to upgrade): MarkupSafe in ./env/lib/python2.7/site-packages (from Jinja2>=2.4->flask->-r /opt/code/requirements.txt (line 1))
   [√] SUCCESS
+> Copying release into live code directory...
+> Moving final build into release environment...

--------------------------------------------------------------------------------
[√] APP SUCCESSFULLY BUILT   ///   DEV URL : test_nanobox.dev
--------------------------------------------------------------------------------

++> STREAMING LOGS (ctrl-c to exit) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

My execution command specify here : https://github.com/harobed/nanobox-python-sample/blob/master/Boxfile#L3 isn't executed.

Other note : the nanobox output say nothing about line executed.

tylerflint commented 8 years ago

The exec provided would work if it were within a web node, instead of the build node, like this:

build:
  runtime: python27

web1:
  exec: "./env/bin/python app.py"

You can find more information here: https://docs.nanobox.io/boxfile/code-services/web/

Thanks!

tylerflint commented 8 years ago

Actually, I think the more proper way to accomplish this would be to use the python engine's "app_module" configuration. More information can be found here: https://engines.nanobox.io/releases/00d59bc3-7943-4082-97b8-44be36055f4b#app_module

harobed commented 8 years ago
...
web1:
    exec: "./env/bin/python app.py

Ok, I'm going to test it.

harobed commented 8 years ago

I've updated https://github.com/harobed/nanobox-python-sample/blob/master/Boxfile I execute :

$ nanobox destroy
$ nanobox run
$ 
...
+> Copying release into live code directory...
+> Moving final build into release environment...
+> Launching Code services
   - Creating web1 container
   - Starting web1 service

--------------------------------------------------------------------------------
[√] APP SUCCESSFULLY BUILT   ///   DEV URL : test_nanobox.dev
--------------------------------------------------------------------------------

++> STREAMING LOGS (ctrl-c to exit) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Next, in another term I run :

$ nanobox dev
[gonano@test_nanobox /code]$ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
gonano       1  0.0  0.0   4348   632 ?        Ss+  11:34   0:00 /bin/sleep 365d
gonano      37  0.0  0.3  18160  3220 ?        Ss   11:34   0:00 /bin/bash
gonano      50  0.0  0.2  15572  2180 ?        R+   11:34   0:00 ps aux

I don't see my python app.

It's a bug ?

tylerflint commented 8 years ago

This is an area where nanobox could do a better job of setting a clear expectation. When you issue the 'nanobox run' command, nanobox will run all of the components and services of your app within docker containers, matching the label (if provided) in the Boxfile. 'nanobox dev' will launch a dev1 docker container with some different behaviors.

In your case, the web service containing the python process will be running in the web1 container, and not in the dev1 container where 'nanobox dev' drops you. If you would like to console into the web1 container and see the python process running, you can do so with the 'console' subcommand, like this:

nanobox console web1

I'm curious to see what you find!

Thanks