getnikola / nikola

A static website and blog generator
https://getnikola.com/
MIT License
2.58k stars 443 forks source link

Nikola serve seems blocked #3597

Open frchalaoux opened 2 years ago

frchalaoux commented 2 years ago

Environment

**Python Version: 3.7.6

**Nikola Version: 8.2.0

**Operating System:MacOS Mojave, safari, firefox, Chrome

Description:

When I start Nikola with "nikola serve" or "nikola serve -b" the 127.0.0.1 page seems blocked. It takes a moment for the page to load but eventually she charges after 30s. The problem comes up often and especially when I regenerate new pages.

Any help ?

François-Régis Chalaoux

Kwpolska commented 2 years ago
  1. Do you have any sort of firewall, antivirus, etc. software installed and enabled?
  2. Are there any log outputs in the terminal when running nikola serve and making a request? Do they also appear after 30 seconds?
  3. What is the output of running time curl -v http://127.0.0.1:8000/ in the terminal?
frchalaoux commented 2 years ago
  1. Do you have any sort of firewall, antivirus, etc. software installed and enabled?

No sort of these softwares installed

  1. Are there any log outputs in the terminal when running nikola serve and making a request? Do they also appear after 30 seconds?
127.0.0.1 - - [05/Feb/2022 18:14:25] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [05/Feb/2022 18:14:33] code 404, message File not found: /Users/frchalaoux/Documents/Drone/Logistique/SI/Development/Nikola/vigne/output/livereload
127.0.0.1 - - [05/Feb/2022 18:14:33] "GET /livereload HTTP/1.1" 404 
  1. What is the output of running time curl -v http://127.0.0.1:8000/ in the terminal?
(SiteGenerators) frchalaoux$ time curl -v http://127.0.0.1:8000/
* Expire in 0 ms for 6 (transfer 0x7fdd87800800)
* Expire in 1 ms for 1 (transfer 0x7fdd87800800)
* Expire in 0 ms for 1 (transfer 0x7fdd87800800)
* Expire in 1 ms for 1 (transfer 0x7fdd87800800)
* Expire in 0 ms for 1 (transfer 0x7fdd87800800)
* Expire in 0 ms for 1 (transfer 0x7fdd87800800)
* Expire in 1 ms for 1 (transfer 0x7fdd87800800)
* Expire in 0 ms for 1 (transfer 0x7fdd87800800)
* Expire in 0 ms for 1 (transfer 0x7fdd87800800)
* Expire in 1 ms for 1 (transfer 0x7fdd87800800)
* Expire in 0 ms for 1 (transfer 0x7fdd87800800)
* Expire in 0 ms for 1 (transfer 0x7fdd87800800)
* Expire in 1 ms for 1 (transfer 0x7fdd87800800)
* Expire in 0 ms for 1 (transfer 0x7fdd87800800)
* Expire in 0 ms for 1 (transfer 0x7fdd87800800)
* Expire in 0 ms for 1 (transfer 0x7fdd87800800)
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x7fdd87800800)
* Connected to 127.0.0.1 (127.0.0.1) port 8000 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:8000
> User-Agent: curl/7.64.0
> Accept: */*
> 

127.0.0.1 - - [05/Feb/2022 18:04:35] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [05/Feb/2022 18:04:35] code 404, message File not found: /Users/frchalaoux/Documents/Drone/Logistique/SI/Development/Nikola/vigne/output/livereload
127.0.0.1 - - [05/Feb/2022 18:04:35] "GET /livereload HTTP/1.1" 404 -
127.0.0.1 - - [05/Feb/2022 18:04:35] "GET / HTTP/1.1" 200 -
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 63079)
Traceback (most recent call last):
  File "/Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
  File "/Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/http/server.py", line 646, in __init__
    super().__init__(*args, **kwargs)
  File "/Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/socketserver.py", line 720, in __init__
    self.handle()
  File "/Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/http/server.py", line 426, in handle
    self.handle_one_request()
  File "/Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/http/server.py", line 414, in handle_one_request
    method()
  File "/Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/http/server.py", line 653, in do_GET
    self.copyfile(f, self.wfile)
  File "/Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/http/server.py", line 844, in copyfile
    shutil.copyfileobj(source, outputfile)
  File "/Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/shutil.py", line 82, in copyfileobj
    fdst.write(buf)
  File "/Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/socketserver.py", line 799, in write
    self._sock.sendall(b)
BrokenPipeError: [Errno 32] Broken pipe
----------------------------------------
127.0.0.1 - - [05/Feb/2022 18:04:35] "GET / HTTP/1.1" 200 -
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: SimpleHTTP/0.6 Python/3.7.6
< Date: Sat, 05 Feb 2022 17:04:35 GMT
< Content-Type: text/html; charset=UTF-8
< Content-Length: 5507
< Cache-Control: no-cache, no-store, must-revalidate
< Pragma: no-cache
< Expires: 0
< 
<!DOCTYPE html>
<html prefix="og: http://ogp.me/ns# article: http://ogp.me/ns/article#
" lang="fr">
<head>
<meta charset="utf-8">
<meta name="description" content="solutions drone et satellite pour l'inspection de vos parcelles de vigne. Gain de temps et d'argent seront notre réponse à notre partenariat. traiter les maladies le stress hydrique diminuer vos intrants, herbicides et pesticides">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>frcopter</title>
<link href="assets/css/all-nocdn.css" rel="stylesheet" type="text/css">
<meta name="theme-color" content="#5670d4">
<meta name="generator" content="Nikola (getnikola.com)">
<link rel="alternate" type="application/rss+xml" title="RSS" hreflang="fr" href="rss.xml">
<link rel="canonical" href="http://vigne.frcopter.fr/">
<link rel="icon" href="favicon.png" sizes="16x16">
<link rel="icon" href="icon_128x128.png" sizes="128x128">
<!--[if lt IE 9]><script src="assets/js/html5.js"></script><![endif]--><style>nav-bar{font-size:50px;}</style>
<meta name="author" content="frcopter">
<meta property="og:site_name" content="frcopter">
<meta property="og:title" content="frcopter">
<meta property="og:url" content="http://vigne.frcopter.fr/">
<meta property="og:description" content="solutions drone et satellite pour l'inspection de vos parcelles de vigne. Gain de temps et d'argent seront notre réponse à notre partenariat. traiter les maladies le stress hydrique diminuer vos intra">
<meta property="og:type" content="article">
<meta property="article:published_time" content="2020-01-27T18:29:38+01:00">
</head>
<body>
<a href="#content" class="sr-only sr-only-focusable">Aller au contenu principal</a>

<!-- Menubar -->

<nav class="navbar navbar-expand-md static-top mb-4
navbar-dark bg-dark
"><div class="container">
<!-- This keeps the margins nice -->
        <!-- <a class="navbar-brand" href="/"> -->
        <a class="navbar-brand" href="http://www.frcopter.fr">
            <img src="http://vigne.frcopter.fr/assets/images/logo_fond-transparent.png" alt="frcopter" id="logo" class="d-inline-block align-top"></a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#bs-navbar" aria-controls="bs-navbar" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="bs-navbar">
            <ul class="navbar-nav mr-auto">
<li class="nav-item">
<a href="viticulture-de-precision/" class="nav-link">Viticulture</a>
                </li>
<li class="nav-item">
<a href="photogrammetrie-et-cartographie/" class="nav-link">Photogrammétrie</a>
                </li>
<li class="nav-item">
<a href="support-et-contact/" class="nav-link">Support et Contact</a>
                </li>
<li class="nav-item">
<a href="about/" class="nav-link">A Propos</a>

            </li>
</ul>
<ul class="navbar-nav navbar-right"></ul>
</div>
<!-- /.navbar-collapse -->
    </div>
<!-- /.container -->
</nav><!-- End of Menubar --><div class="container" id="content" role="main">
    <div class="body-content">
        <!--Body content-->

<article class="post-text storypage" itemscope="itemscope" itemtype="http://schema.org/Article"><header></header><div class="e-content entry-content" itemprop="articleBody text">
    <p style="font-size: larger;">La saison viticole 2022 est en pleins préparatifs.</p>
<p style="font-size: larger;">Quel est votre besoin pour cette  année ? </p>
<p style="font-size: larger;">Quels moyens allez-vous y consacrer pour l'atteindre ?</p>

<hr>
<p>frcopter vous propose ses solutions drone et satellite pour l'inspection de vos parcelles vigne dans un partenariat tout au long de la saison. Gagnez du temps pour l'observation et de l'argent pour traiter les maladies, le stress hydrique et diminuer vos intrants: engrais, herbicides et pesticides.</p>
<table style="width:100%;border:1px"><tr>
<td>
        <ul>
<li> Regroupement parcellaire</li>
        <li> Adaptation des pratiques culturales</li>
        <li> Homogénéisation des parcelles</li>
        <li> Détection de maladies</li>
        <li> Comptage automatisé des manquants</li>
        <li> Détection d’adventices</li>
        <li> Dégâts météorologiques et du gibier</li>
        <li> Gestion de l'eau</li>
        <li> Cartographie de vos parcelles</li>
        </ul>
</td>
        <td><img src="images/viticulture-precision/Vigne_drone.png" alt="" width="683" height="512"></td>
    </tr></table>
<hr>
<p>Voici <a class="reference external" href="detail-viticulture/">quelques exemples</a> qui vous donnent un aperçu plus détaillé de nos prestations.</p>
<p>Pour vos demandes d'information et de devis contactez-nous par <a class="reference external" href="mailto:contact@frcopter.fr">courriel</a> et nous reviendrons vers vous.</p>
    </div>

</article><!--End of body content--><footer id="footer">
            Contents © 2022         <a href="mailto:contact@frcopter.fr">frcopter</a> - Powered by         <a href="https://getnikola.com" rel="nofollow">Nikola</a>         

        </footer>
</div>
</div>

        <script src="assets/js/all-nocdn.js"></script><script>
    baguetteBox.run('div#content', {
        ignoreClass: 'islink',
        captions: function(element) {
            return element.getElementsByTagName('img')[0].alt;
    }});
    </script>
</body>
</html>
* Closing connection 0

real    0m30.590s
user    0m0.005s
sys 0m0.005s
Kwpolska commented 2 years ago

Do you have the same slowdowns if you use Python’s http.server directly? cd output; python -m http.server to launch it

frchalaoux commented 2 years ago

I have another message but it seems to work without slow-down

(SiteGenerators) frchalaoux$ python -m http.server Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ... 127.0.0.1 - - [05/Feb/2022 18:44:53] "GET / HTTP/1.1" 200 - 127.0.0.1 - - [05/Feb/2022 18:45:00] code 404, message File not found 127.0.0.1 - - [05/Feb/2022 18:45:00] "GET /livereload HTTP/1.1" 404 - 127.0.0.1 - - [05/Feb/2022 18:46:00] code 404, message File not found 127.0.0.1 - - [05/Feb/2022 18:46:00] "GET /livereload HTTP/1.1" 404 -

Regulary it display :

127.0.0.1 - - [05/Feb/2022 18:46:00] code 404, message File not found 127.0.0.1 - - [05/Feb/2022 18:46:00] "GET /livereload HTTP/1.1" 404 -

Kwpolska commented 2 years ago

The query to /livereload seems strange if you get it from curl. But if not, you might have a livereload browser extension that always calls /livereload in the background.

Since you cannot reproduce using http.server, we might need a profile to see what’s going on.

Run nikola serve with the following command: python -m cProfile -o profileout.bin -m nikola serve. This will launch the server — then try to navigate to your site (via your browser or via curl). When it’s done loading (so after the 30 second delay), kill it with ^C and attach the profileout.bin file here. (If it’s too large or won’t attach due to the strange extension, put it in a .zip archive or something)

frchalaoux commented 2 years ago

[Uploading profileout.bin.zip…]()

Kwpolska commented 2 years ago

@frchalaoux The upload didn’t succeed, I think you submitted your comment too early.

frchalaoux commented 2 years ago

profileout.bin.zip

Kwpolska commented 2 years ago
Sat Feb  5 19:13:55 2022    profileout.bin

         986877 function calls (962965 primitive calls) in 80.039 seconds

   Ordered by: cumulative time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
    823/1    0.004    0.000   80.040   80.040 {built-in method builtins.exec}
        1    0.000    0.000   80.040   80.040 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/runpy.py:195(run_module)
        1    0.000    0.000   79.644   79.644 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/runpy.py:62(_run_code)
        1    0.000    0.000   79.644   79.644 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/site-packages/nikola/__main__.py:27(<module>)
        1    0.000    0.000   79.641   79.641 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/site-packages/nikola/__main__.py:67(main)
        1    0.000    0.000   79.638   79.638 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/site-packages/nikola/__main__.py:315(run)
        1    0.000    0.000   79.203   79.203 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/site-packages/doit/doit_cmd.py:126(run)
        1    0.000    0.000   79.203   79.203 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/site-packages/doit/cmd_base.py:141(parse_execute)
        1    0.000    0.000   79.203   79.203 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/site-packages/nikola/plugin_categories.py:140(execute)
        1    0.000    0.000   79.203   79.203 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/site-packages/nikola/plugins/command/serve.py:111(_execute)
        1    0.001    0.001   79.166   79.166 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/socketserver.py:215(serve_forever)
        4    0.000    0.000   60.004   15.001 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/socketserver.py:303(_handle_request_noblock)
        4    0.000    0.000   60.004   15.001 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/socketserver.py:341(process_request)
        4    0.000    0.000   60.004   15.001 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/socketserver.py:358(finish_request)
        4    0.000    0.000   60.004   15.001 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/http/server.py:642(__init__)
        4    0.000    0.000   60.003   15.001 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/socketserver.py:714(__init__)
        4    0.000    0.000   60.003   15.001 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/http/server.py:422(handle)
        4    0.000    0.000   60.003   15.001 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/http/server.py:385(handle_one_request)
       35    0.000    0.000   60.000    1.714 {method 'readline' of '_io.BufferedReader' objects}
        4    0.000    0.000   60.000   15.000 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/socket.py:575(readinto)
        4   60.000   15.000   60.000   15.000 {method 'recv_into' of '_socket.socket' objects}
       41    0.001    0.000   19.161    0.467 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/selectors.py:402(select)
       41   19.161    0.467   19.161    0.467 {method 'poll' of 'select.poll' objects}
   834/76    0.003    0.000    0.702    0.009 <frozen importlib._bootstrap>:663(_load_unlocked)
   774/80    0.002    0.000    0.697    0.009 <frozen importlib._bootstrap_external>:722(exec_module)
  1037/82    0.000    0.000    0.690    0.008 <frozen importlib._bootstrap>:211(_call_with_frames_removed)
   815/41    0.004    0.000    0.687    0.017 <frozen importlib._bootstrap>:978(_find_and_load)
   813/40    0.002    0.000    0.687    0.017 <frozen importlib._bootstrap>:948(_find_and_load_unlocked)
   208/71    0.000    0.000    0.568    0.008 {built-in method builtins.__import__}
        1    0.000    0.000    0.435    0.435 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/site-packages/nikola/nikola.py:1027(init_plugins)
      2/1    0.000    0.000    0.396    0.396 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/runpy.py:102(_get_module_details)
        1    0.000    0.000    0.396    0.396 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/site-packages/nikola/__init__.py:27(<module>)
        1    0.000    0.000    0.394    0.394 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/site-packages/nikola/nikola.py:27(<module>)
2923/1306    0.002    0.000    0.355    0.000 <frozen importlib._bootstrap>:1009(_handle_fromlist)
        2    0.021    0.011    0.338    0.169 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/site-packages/yapsy/PluginManager.py:480(loadPlugins)
       65    0.001    0.000    0.300    0.005 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/site-packages/yapsy/PluginManager.py:572(_importModule)
       65    0.000    0.000    0.296    0.005 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/imp.py:219(load_module)
       65    0.000    0.000    0.295    0.005 <frozen importlib._bootstrap>:686(_load)
        1    0.000    0.000    0.174    0.174 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/site-packages/nikola/filters.py:30(<module>)
      781    0.003    0.000    0.154    0.000 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/re.py:271(_compile)
      397    0.000    0.000    0.152    0.000 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/re.py:232(compile)
        5    0.000    0.000    0.151    0.030 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/imp.py:199(load_package)
        1    0.000    0.000    0.148    0.148 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/site-packages/pkg_resources/__init__.py:16(<module>)
      383    0.002    0.000    0.147    0.000 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/sre_compile.py:759(compile)
       60    0.000    0.000    0.145    0.002 /Users/frchalaoux/opt/anaconda3/envs/SiteGenerators/lib/python3.7/imp.py:165(load_source)
2723/2711    0.038    0.000    0.132    0.000 {built-in method builtins.__build_class__}
      775    0.006    0.000    0.128    0.000 <frozen importlib._bootstrap_external>:793(get_code)

image

The calls that take the longest in this profile are in socketserver and other parts of the sockets stack, they don’t seem Nikola-related at all. Considering http.server works fine, and considering Nikola uses http.server internally, I really can’t figure out what goes wrong.

Could you try with some other Python build (eg. homebrew’s python@3.10 package)?

frchalaoux commented 2 years ago

Hi, With which tool did you analyse this bin file ?

Kwpolska commented 2 years ago

pstats + flameprof

frchalaoux commented 2 years ago

Have you a script to use pstats + flameprof ?