V
V
VicTHOR2020-11-17 17:12:28
Nginx
VicTHOR, 2020-11-17 17:12:28

Why is nginx holding the map file?

Some directory contains files bootstrap.min.cssand bootstrap.min.css.map. With the help of javascript, these files are transferred from one directory to another, and the second one is cleared in advance.
There is this business on a virtualka, in "shared folders". At the first start of the virtual machine, the script runs successfully, but the next time an error is generated

Error: ETXTBSY: text file is busy, unlink '/path/to/bootstrap.min.css.map'

I look who is busy with this file
# lsof ./path/to/bootstrap.min.css.map 

COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF  NODE NAME
nginx   3559 nginx   24r   REG   0,42   646986 10378 ./path/to/bootstrap.min.css.map

kill -9 3559helps. But what is wrong, how to do without it?

nginx.conf
user nginx vboxsf;
worker_processes 2;
pid /run/nginx.pid;

include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
    multi_accept on;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  off;
    error_log   /var/log/nginx/error.log crit;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        text/html;
    charset             UTF-8;

    keepalive_timeout     20;
    client_header_timeout 20;
    client_body_timeout   20;
    send_timeout          20;

    reset_timedout_connection on;

    gzip  on;
    gzip_buffers 16 8k;
    gzip_comp_level 6;
    gzip_http_version 1.1;
    gzip_min_length 256;
    gzip_proxied any;
    gzip_vary on;
    gzip_types
      text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
      text/javascript application/javascript application/x-javascript
      text/x-json application/json application/x-web-app-manifest+json
      text/css text/plain text/x-component
      font/opentype application/x-font-ttf application/vnd.ms-fontobject
      image/x-icon;
    gzip_disable "msie6";

    open_file_cache max=65000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;

server {
    server_name  some.name;
    root         /some/path/;

    access_log   off;
    error_log    /var/log/nginx/some..error.log;

    # Cache images 1 year
    location ~* \.(jpg|jpeg|gif|png|ico|woff|woff2)$ {
        access_log        off;
        log_not_found     off;
        expires           360d;
    }

    # Don't store files log
    location ~* \.(css|js|xml)$ {
        access_log        off;
        log_not_found     off;
    }

    # Exclude hidden directory
    location ~ /\. {
        access_log off;
        log_not_found off; 
        deny all;
    }

    index index.php index.html;

    error_page 404 /index.php;

    location / {
        rewrite ^/(.*)/$ /$1 permanent;
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        rewrite ^/(.*)/$ /$1 permanent;

        server_tokens off;
        client_max_body_size 3m;
        client_body_buffer_size 128k;

        # regex to split $uri to $fastcgi_script_name and $fastcgi_path
        fastcgi_split_path_info ^(.+\.php)(/.+)$;

        # Check that the PHP script exists before passing it
        try_files $fastcgi_script_name =404;

        # Bypass the fact that try_files resets $fastcgi_path_info
        # see: http://trac.nginx.org/nginx/ticket/321
        set $path_info $fastcgi_path_info;
        fastcgi_param PATH_INFO $path_info;

        fastcgi_index index.php;
        include fastcgi.conf;

        fastcgi_pass unix:/var/run/php-fpm/some.sock;
    }
}
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sand, 2020-11-18
@VicTHOR

open_file_cache max=65000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;

here we can store "descriptors of open files, information about their size and modification time". Try turning it off.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question