Welcome! Log In Create A New Profile

Advanced

I can not configure the python module through the official Nginx Unit documentation?

Posted by avpdnepr 
2018/03/13 12:10:37 [info] 2220#2220 "example_python" application started
2018/03/13 12:10:37 [emerg] 2220#2220 Python failed to import module "wsgi"
2018/03/13 12:10:37 [notice] 1625#1625 process 2220 exited with code 1
2018/03/13 12:10:37 [warn] 1632#1632 failed to start application
"example_python"

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,279020,279020#msg-279020

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
On Tuesday 13 March 2018 11:46:48 avpdnepr wrote:
> 2018/03/13 12:10:37 [info] 2220#2220 "example_python" application started
> 2018/03/13 12:10:37 [emerg] 2220#2220 Python failed to import module "wsgi"
> 2018/03/13 12:10:37 [notice] 1625#1625 process 2220 exited with code 1
> 2018/03/13 12:10:37 [warn] 1632#1632 failed to start application
> "example_python"
>

This means that Python interpreter is unable to load your application.
You should check that the path is correct and Unit application process
have enough rights.

wbr, Valentin V. Bartenev

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Valentin V. Bartenev Wrote:
-------------------------------------------------------
> On Tuesday 13 March 2018 11:46:48 avpdnepr wrote:
> > 2018/03/13 12:10:37 [info] 2220#2220 "example_python" application
> started
> > 2018/03/13 12:10:37 [emerg] 2220#2220 Python failed to import module
> "wsgi"
> > 2018/03/13 12:10:37 [notice] 1625#1625 process 2220 exited with code
> 1
> > 2018/03/13 12:10:37 [warn] 1632#1632 failed to start application
> > "example_python"
> >
>
> This means that Python interpreter is unable to load your application.
> You should check that the path is correct and Unit application process
> have enough rights.
>
> wbr, Valentin V. Bartenev
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

root 1625 0.0 0.0 22632 2212 ? Ss 11:48 0:00 unit: main
[/usr/sbin/unitd --log /var/log/unit.log --pid /run/unit.pid]
nobody 1631 0.0 0.0 32744 2072 ? S 11:48 0:00 unit:
controller
nobody 1632 0.0 0.0 106736 2176 ? Sl 11:48 0:00 unit:
router
www-php 1633 0.0 0.3 129272 15056 ? S 11:48 0:00 unit:
"blogs" application
www-php 1634 0.0 0.3 129276 15112 ? S 11:48 0:00 unit:
"blogs" application
www-php 1635 0.0 0.3 129276 15112 ? S 11:48 0:00 unit:
"blogs" application
www-php 1636 0.0 0.3 129276 15112 ? S 11:48 0:00 unit:
"blogs" application
www-php 1637 0.0 0.3 129276 15116 ? S 11:48 0:00 unit:
"blogs" application
www-php 1638 0.0 0.3 129276 15112 ? S 11:48 0:00 unit:
"blogs" application
www-php 1639 0.0 0.3 129276 15116 ? S 11:48 0:00 unit:
"blogs" application
www-php 1640 0.0 0.3 129276 15112 ? S 11:48 0:00 unit:
"blogs" application
www-php 1641 0.0 0.3 129276 15116 ? S 11:48 0:00 unit:
"blogs" application
www-php 1642 0.0 0.3 129276 15120 ? S 11:48 0:00 unit:
"blogs" application
www-php 1643 0.0 0.3 129276 15120 ? S 11:48 0:00 unit:
"blogs" application
www-php 1644 0.0 0.3 129276 15120 ? S 11:48 0:00 unit:
"blogs" application
www-php 1645 0.0 0.3 129276 15120 ? S 11:48 0:00 unit:
"blogs" application
www-php 1646 0.0 0.3 129276 15116 ? S 11:48 0:00 unit:
"blogs" application
www-php 1647 0.0 0.3 129276 15116 ? S 11:48 0:00 unit:
"blogs" application
www-php 1648 0.0 0.3 129276 15116 ? S 11:48 0:00 unit:
"blogs" application
www-php 1649 0.0 0.3 129276 15116 ? S 11:48 0:00 unit:
"blogs" application
www-php 1650 0.0 0.3 129276 15116 ? S 11:48 0:00 unit:
"blogs" application
www-php 1651 0.0 0.3 129276 15116 ? S 11:48 0:00 unit:
"blogs" application
www-php 1652 0.0 0.3 129280 15116 ? S 11:48 0:00 unit:
"blogs" application
root 3910 0.0 0.0 12944 932 pts/0 S+ 16:24 0:00 grep
--color=auto unit

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,279020,279024#msg-279024

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
{
"listeners": {
"*:8300": {
"application": "blogs"
},
"*:8301": {
"application": "cart"
}
},

"applications": {
"blogs": {
"type": "php",
"processes": 20,
"user": "www-php",
"group": "www-php",
"root": "/var/www",
"index": "index.php"
},
"cart": {
"type": "python",
"processes": 10,
"user": "root",
"group": "root",
"path": "/var/www/app"
}
}
}

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,279020,279025#msg-279025

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
On Tuesday 13 March 2018 12:28:00 avpdnepr wrote:
> {
> "listeners": {
> "*:8300": {
> "application": "blogs"
> },
> "*:8301": {
> "application": "cart"
> }
> },
>
> "applications": {
> "blogs": {
> "type": "php",
> "processes": 20,
> "user": "www-php",
> "group": "www-php",
> "root": "/var/www",
> "index": "index.php"
> },
> "cart": {
> "type": "python",
> "processes": 10,
> "user": "root",
> "group": "root",
> "path": "/var/www/app"
> }
> }
> }
>

Could you provide ls -l /var/www/app ?

Also in you Unit log the application was "example_python"
but in your configuration the only Python application is
called "cart".

wbr, Valentin V. Bartenev

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
[email protected]:~# ls -l /var/www/app
total 0
[email protected]:~#

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,279020,279027#msg-279027

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
On Tuesday 13 March 2018 12:43:10 avpdnepr wrote:
> [email protected]:~# ls -l /var/www/app
> total 0
> [email protected]:~#
>

So, you have no Python application in /var/www/app.
What are you trying to run then and where it is?

wbr, Valentin V. Bartenev

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
[email protected]:~# cat /var/www/app/index.py
import sys

def application(environ, start_response):
body = sys.version.encode("utf-8")
status = "200 OK"
headers = [('Content-type','text/plain')]
start_response(status, headers)
return body


[email protected]:~# curl -X PUT -d @/root/unit_json/start.json --unix-socket
/var/run/control.unit.sock http://localhost/
{
"error": "Failed to apply new configuration."
}
[email protected]:~#

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,279020,279031#msg-279031

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
[email protected]:~# cat /root/unit_json/start.json
{
"listeners": {
"*:8300": {
"application": "blogs"
},
"*:8301": {
"application": "cart"
}
},

"applications": {
"blogs": {
"type": "php",
"processes": 20,
"user": "www-php",
"group": "www-php",
"root": "/var/www",
"index": "index.php"
},
"cart": {
"type": "python",
"processes": 10,
"module": "wsgi",
"user": "root",
"group": "root",
"path": "/var/www/app"
}
}
}
[email protected]:~#

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,279020,279032#msg-279032

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
On Tuesday 13 March 2018 13:25:47 avpdnepr wrote:
> [email protected]:~# cat /root/unit_json/start.json
> {
> "listeners": {
> "*:8300": {
> "application": "blogs"
> },
> "*:8301": {
> "application": "cart"
> }
> },
>
> "applications": {
> "blogs": {
> "type": "php",
> "processes": 20,
> "user": "www-php",
> "group": "www-php",
> "root": "/var/www",
> "index": "index.php"
> },
> "cart": {
> "type": "python",
> "processes": 10,
> "module": "wsgi",
> "user": "root",
> "group": "root",
> "path": "/var/www/app"
> }
> }
> }

Since your Python application() callable is inside the
/var/www/app/index.py file, then your module should
be called "index", not "wsgi".

See the Python documentation about how it works:
https://docs.python.org/3/tutorial/modules.html#the-module-search-path

wbr, Valentin V. Bartenev

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login