Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factories not supported?? #105

Closed
jackadam1981 opened this issue Nov 9, 2018 · 3 comments
Closed

Factories not supported?? #105

jackadam1981 opened this issue Nov 9, 2018 · 3 comments

Comments

@jackadam1981
Copy link

Checking for script in /app/prestart.sh
Running script /app/prestart.sh
/usr/lib/python2.7/site-packages/supervisor/options.py:298: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
'Supervisord is running as root and it is searching '
2018-11-09 17:30:03,755 CRIT Supervisor running as root (no user in config file)
2018-11-09 17:30:03,757 INFO Included extra file "/etc/supervisor.d/supervisord.ini" during parsing
2018-11-09 17:30:03,807 INFO RPC interface 'supervisor' initialized
2018-11-09 17:30:03,809 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2018-11-09 17:30:03,810 INFO supervisord started with pid 1
2018-11-09 17:30:04,814 INFO spawned: 'nginx' with pid 9
2018-11-09 17:30:04,822 INFO spawned: 'uwsgi' with pid 10
[uWSGI] getting INI configuration from /app/uwsgi.ini
[uWSGI] getting INI configuration from /etc/uwsgi/uwsgi.ini
*** Starting uWSGI 2.0.17 (64bit) on [Fri Nov 9 17:30:04 2018] ***
compiled with version: 6.4.0 on 27 March 2018 12:43:27
os: Linux-4.18.16-300.fc29.x86_64 #1 SMP Sat Oct 20 23:24:08 UTC 2018
nodename: 7fbf75965139
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /app
detected binary path: /usr/sbin/uwsgi
your processes number limit is 1048576
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /tmp/uwsgi.sock fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.6.5 (default, Aug 22 2018, 14:20:40) [GCC 6.4.0]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x55f461042fa0
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 1239640 bytes (1210 KB) for 16 cores
*** Operational MODE: preforking ***
2018-11-09 17:30:06,093 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2018-11-09 17:30:06,095 INFO success: uwsgi entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. GAME OVER ***
2018-11-09 17:30:06,296 INFO exited: uwsgi (exit status 22; not expected)
2018/11/09 17:30:07 [error] 11#11: *1 connect() to unix:///tmp/uwsgi.sock failed (111: Connection refused) while connecting to upstream, client: 192.168.43.228, server: , request: "GET / HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock:", host: "192.168.43.77:85"
192.168.43.228 - - [09/Nov/2018:17:30:07 +0800] "GET / HTTP/1.1" 502 173 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0" "-"
2018-11-09 17:30:07,265 INFO spawned: 'uwsgi' with pid 12
[uWSGI] getting INI configuration from /app/uwsgi.ini
[uWSGI] getting INI configuration from /etc/uwsgi/uwsgi.ini
*** Starting uWSGI 2.0.17 (64bit) on [Fri Nov 9 17:30:07 2018] ***
compiled with version: 6.4.0 on 27 March 2018 12:43:27
os: Linux-4.18.16-300.fc29.x86_64 #1 SMP Sat Oct 20 23:24:08 UTC 2018
nodename: 7fbf75965139
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /app
detected binary path: /usr/sbin/uwsgi
your processes number limit is 1048576
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /tmp/uwsgi.sock fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.6.5 (default, Aug 22 2018, 14:20:40) [GCC 6.4.0]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x55acdbc52fa0
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 1239640 bytes (1210 KB) for 16 cores
*** Operational MODE: preforking ***

i try use Application Factories in this docker.
main.py is :

from flask import Flask
from flask import current_app, Blueprint, render_template
admin = Blueprint('admin', name, url_prefix='/')
@admin.route('/')
def hello():
return "Hello World test "
def create_app():
app = Flask(name)
app.register_blueprint(admin)
return app
if name == "main":
app = create_app()
app.run(host='0.0.0.0', debug=True, port=80)

work great on pycharm.
not work in this docker.
is supported?

file:
.:
app
Dockerfile

./app:
main.py

Dockerfile:
FROM tiangolo/uwsgi-nginx-flask:python3.6-alpine3.7
COPY ./app /app

@tiangolo
Copy link
Owner

tiangolo commented Nov 9, 2018

Hmm, I'm not sure if I understand your issue.

Could you please create a repository that replicates your problem? That way I can check it and try to see the issue.

@jackadam1981
Copy link
Author

@tiangolo
Copy link
Owner

tiangolo commented Nov 9, 2018

Your app is only being created when you call the file directly.

That's because of the:

if __name__ == "__main__":

You need to create your app before that section. That way, uWSGI can import and call it.

That's why the error log shows:

zzcld_1  | unable to load app 0 (mountpoint='') (callable not found or import error)
zzcld_1  | *** no app loaded. GAME OVER ***
zzcld_1  | 2018-11-09 17:23:49,112 INFO exited: uwsgi (exit status 22; not expected)
zzcld_1  | 2018-11-09 17:23:50,114 INFO gave up: uwsgi entered FATAL state, too many start retries too quickly

I just sent you the fix as a PR: https://github.com/jackadam1981/testflask/pull/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants