UWSGI can't import module 'mysite' with nginx and flask

222

Moving the settings from nginx to uswgi solved my problem:

mysite.ini:

[uwsgi]
vhost=true
socket=/tmp/mysite.sock
venv = /var/www/mysite/venv
chdir = /var/www/mysite
module = app
callable = app

nginx config file:

server {
        listen   80;
        server_name my_ipaddr;

        location /static {
          alias /var/www/mysite/static;
        }

        location / {
              include      uwsgi_params;
              uwsgi_pass   unix:/tmp/mysite.sock;
        }
Share:
222

Related videos on Youtube

netzding
Author by

netzding

Updated on September 18, 2022

Comments

  • netzding
    netzding over 1 year

    im updating a project from sf2.6(php5.6) to sf3.4(php7.1)... its going well but now im stuck with an error i cant figure out how to fix it

    error output: PHP message: PHP Fatal error: Uncaught Symfony\\Component\\Debug\\Exception\\FatalThrowableError: Type error: Argument 2 passed to Sonata\\FormatterBundle\\Formatter\\Pool::add() must implement interface Sonata\\FormatterBundle\\Formatter\\FormatterInterface, boolean given, called in /var/www/var/cache/dev/ContainerMklcxqq/appDevDebugProjectContainer.php on line 4924 in /var/www/vendor/sonata-project/formatter-bundle/src/Formatter/Pool.php:43\nStack trace:\n#0 /var/www/var/cache/dev/ContainerMklcxqq/appDevDebugProjectContainer.php(4924): Sonata\\FormatterBundle\\Formatter\\Pool->add('twig', true, NULL)\n#1 /var/www/var/cache/dev/ContainerMklcxqq/appDevDebugProjectContainer.php(3475): ContainerMklcxqq\\appDevDebugProjectContainer->getSonata_Formatter_PoolService()\n#2 /var/www/var/cache/dev/ContainerMklcxqq/getAssetic_AssetManagerService.php(8): ContainerMklcxqq\\appDevDebugProjectContainer->getTwigService()\n#3 /var/www/var/cache/dev/ContainerMklcxqq/appDevDebugProjectContainer.php(1349): require('/var/www/var/ca...')\n#4 /v...\n'

    if i check the mentioned line (4924) in the container i find:

    $instance->add('twig', ${($_ = isset($this- >services['sonata.formatter.text.twigengine']) ? $this- 
    >services['sonata.formatter.text.twigengine'] : $this- 
    >getSonata_Formatter_Text_TwigengineService()) && false ?: '_'}, NULL);
    

    when i check the actual service with "bin/console debug:container sonata.formatter.text.twigengine" i get the following, which is good, i guess:

    Information for Service "sonata.formatter.text.twigengine"
    ==========================================================
    
     ---------------- ------------------------------------------------
      Option           Value
     ---------------- ------------------------------------------------
      Service ID       sonata.formatter.text.twigengine
      Class            Sonata\FormatterBundle\Formatter\TwigFormatter
      Tags             sonata.text.formatter
      Public           no
      Synthetic        no
      Lazy             no
      Shared           yes
      Abstract         no
      Autowired        no
      Autoconfigured   no
     ---------------- ------------------------------------------------
    

    and finally i checked the actual TwigFormatter class, which leads to this post:

    final class TwigFormatter implements FormatterInterface
    

    how is this error possible and am i supposed to fix this or is any package update needed? im using the newest version of the sonata-project/formatter-bundle and also the newest version of twig/twig.

    help and explanation is much appreciated. thanks guys.

    • Deer Hunter
      Deer Hunter almost 11 years
      Have you checked your paths? A possibly similar problem was solved here
    • Mark Berger
      Mark Berger almost 11 years
      I'm not able to post an answer right now because I don't have enough reputation, but I solved this by moving the uwsgi settings from nginx to mysite.ini.
    • Veve
      Veve over 5 years
      You'll have to check all changelogs and upgrade notices of Symfony, and also of sonata and twig.
    • netzding
      netzding over 5 years
      i fixed all codebase related deprecations before updating - but well, i will take another look then
    • Veve
      Veve over 5 years
      This bug seems to come from Sonata and Symfony themselves, see github.com/sonata-project/SonataAdminBundle/issues/5238 then github.com/symfony/symfony/issues/28658