w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Django, nginx and uWSGI caching results until uWSGI/MySQL restart
I had the same behavior and found this post https://plus.google.com/u/0/101898908470597791359/posts/AuMJdgEo93k Adding this line on settings.py (only the OPTIONS key) on Django: DATABASES = { 'default': { 'OPTIONS': { "init_command": "SET storage_engine=INNODB, SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED", } } } seems to have resolved the problem.

Categories : Mysql

Python: uWSGI configuration for NGINX+FLASK
This question is popular now, so I've improved this answer a bit. I've moved the most important points from the comments. Yep, that's the normal behavior. Nginx's master process needs root privileges to manage listening sockets on the machine. This forum thread states that you can change it, but it may cause problems. However, Nginx does allow to change the owner of the worker processes. It depends on how the uWSGI was installed. If uWSGI was installed via apt-get you can start (stop, restart) like this: service uwsgi <action> You installed uWSGI via pip, so the daemonize option will do the trick: /path/to/uwsgi --daemonize /path/to/logfile You can start it under any user you want, BUT if you decide to run it under root, you should specify the gid and uid options. uWSGI's bes

Categories : Python

Flask + uwsgi + nginx + debug. 502 error instead of debugger page
Flask debug=True does not work when going through uWSGI may help. Essentially, uwsgi is not intended for development environments where you want debugging info in the browser. It's a production server. possibly adding in app.debug = true may help, after you have instantiated the Flask object, but otherwise, to get a proper debugger, use the flask internal server for development.

Categories : Nginx

How to track down a Python/Django/uwsgi/nginx timeout
You have a pretty "strange" setup: nginx -> uwsgi http router -> uwsgi instead of nginx -> uwsgi maybe you have some good reason for it, but in such a case you need to set the timeout between uwsgi http router and uwsgi via --http-timeout 1800 If the http router is not you want/need you can just let uwsgi speaks http with the --http-socket option

Categories : Python

Python bottle vs uwsgi/bottle vs nginx/uwsgi/bottle
Flask vs Bottle comes down to a couple of things for me. How simple is the app. If it is very simple, then bottle is my choice. If not, then I got with Flask. The fact that bottle is a single file makes it incredibly simple to deploy with by just including the file in our source. But the fact that bottle is a single file should be a pretty good indication that it does not implement the full wsgi spec and all of its edge cases. What does the app do. If it is going to have to render anything other than Python->JSON then I go with Flask for its built in support of Jinja2. If I need to do authentication and/or authorization then Flask has some pretty good extensions already for handling those requirements. If I need to do caching, again, Flask-Cache exists and does a pretty good job w

Categories : Python

nginx loadbalancing in uwsgi
The first approach is a lot saner and avoids nginx to pass requests to a worker already busy. You may find some blog posts or doc about the thundering herd problem, i suggest you to read this: http://uwsgi-docs.readthedocs.org/en/latest/articles/SerializingAccept.html basically unless you are on very specific needs (and limits) the first approach is the way to go.

Categories : Nginx

Django app with Nginx + uWSGI on Amazon EC2
Simple Example used FastCGI Deamon in Amazon EC2 django.sh -> https://gist.github.com/romuloigor/5707566 nginx.conf -> https://gist.github.com/romuloigor/5707527

Categories : Django

Setting up django with uwsgi and nginx
ImportError: Import by filename is not supported. The --module directive expect a module, not a file. You should use --wsgi-file instead.

Categories : Python

nginx hanging for subdomain
Probably an issue with the FastCGI handler (are you using php-fpm?) running at 127.0.0.1:9000 - is it running and accepting connections? Debug it by SSHing to that machine and running: curl -vv http://127.0.0.1:9000/ What happens?

Categories : PHP

Difference between nginx module and uWSGI plugin
To be nginx-friendly a module must be non-blocking and must not use calls like fork(). If you can write a nginx module like this, use the nginx approach. The problem is that all of the current available nginx modules for mongodb are blocking (they generally use threadpools but can potentially blocks). The only solution would be reimplementing the mongodb protocol (check this project http://mojolicio.us/perldoc/Mango) without using the currently available libraries. On the other side uWSGI has not such limits (it can use processes, threads and coroutines), and a gridfs module is already available: http://uwsgi-docs.readthedocs.org/en/latest/GridFS.html The problem is that there is no doc about writing uwsgi plugins, so you have to base yourself on the current available ones Btw, you ne

Categories : Nginx

nginx, django -- uwsgi does not see POST data
x=request.body This should be the first line in any django app ran by wsgi. Then POST DATA works. Django just must read the body of request immediately if it is used later. However, there still is this problem: invalid uwsgi request (current strsize: 16705). skip. So I it is difficult to use uwsgi in this setting. I solved this by the use of fcgi, which does not have such limits. Justification: strsize is not configurable -- http://comments.gmane.org/gmane.comp.python.wsgi.uwsgi.general/5712 Edit: Roberto is right -- strsize is unrelated to request's body and it WORKS even in uwsgi. Debugging a problem during travelling, nights etc is not always a good idea ;) However, Django must read the body request immediately and this is beyond doubt. The request's body must be read prior doing a

Categories : Python

502 Bad Gateway error Nginx and uWSGI in deploying Flask app
With uwsgi_pass 127.0.0.1:9001; you declared to Nginx your intent to talk to uWSGI through TCP socket, but have not warned uWSGI about it. Try adding a corresponding socket line to your /etc/default/uwsgi file: PYTHONPATH=/var/www/reframeit-im MODULE=wsgi socket=127.0.0.1:9001

Categories : Nginx

Nginx+bottle+uwsgi Server returning 404 on every request
Are you sure that NGINX and UWSGI are working properly? Lot's of things could be wrong, I recommend you to follow this guide: https://uwsgi.readthedocs.org/en/latest/tutorials/Django_and_nginx.html It's a step by step to setup NGINX and UWSGI with Django but I'm pretty sure you can apply it to any other web app than Django.

Categories : Python

Mongodb replica set auto reconect don't work after down and up for nginx + uwsgi with several processes
After a change in your replica set (no primary, new primary, etc.), the next operation will throw an AutoReconnect exception. After that one failed operation, the underlying PyMongo MongoReplicaSetClient will reconnect to the replica set, and future operations may succeed. If there is a new primary, MongoReplicaSetClient will find it and future operations will succeed. If there is no primary, no operations can succeed unless you set your ReadPreference to PRIMARY_PREFERRED. See the docs here: http://mongoengine-odm.readthedocs.org/en/latest/guide/connecting.html#replicasets The reconnection process must happen once per uwsgi process. So if there is a change to your replica set, you can expect one AutoReconnect exception per uwsgi process.

Categories : Python

Where is my nginx being configured? Changing nginx.conf still brings me to the 'Welcome to nginx' page
when you rewrited the nginx.conf in the folder of source code of nginx and installed it firstly, it will be copied to /usr/local/nginx/conf/nginx.conf (without specially modification of the configure in the folder of source code). But when you do this secondly, the nginx.conf in the folder of source code will be copied to /usr/local/nginx/conf/nginx.conf.defualt,and it usually don't work unless you use nginx -c /usr/local/nginx/conf/nginx.conf.defualt to assign its configure file evertime. There is a line NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" in your script above,which indicates the configure file clearly. To handle this, I suggest rewrite /usr/local/nginx/conf/nginx.conf (not the one in the folder of source code) instead.

Categories : Nginx

uwsgi: find: `/etc/uwsgi/s-enabled': No such file or directory
Check your uwsgi config file, it should probably be /etc/uwsgi/apps-enabled this directory holds the uwsgi app's ini files either via symlinks from directory /etc/uwsgi/apps-available/ or you can have ini files directly here. example with symlink: ln -s /etc/uwsgi/apps-available/testApp.ini /etc/uwsgi/apps-enabled/testApp.ini Installation of uwsgi and it's configuration on ubuntu can be found here django + uwssgi + nginx on ubuntu Installation of same on centOS6 can be found here uwsgi + gevent + flask + nginx + mongodb on centOS6

Categories : Misc

uWSGI for running Python 2 and Python3 with django
Your uWSGI binary is linked with a specific libpython (the 3.3 one). You have to build a second copy of uWSGI for python2.7 or use a modular build: (from source directory) python3 uwsgiconfig.py --build nolang python3 uwsgiconfig.py --plugin plugins/python nolang python33 python2 uwsgiconfig.py --plugin plugins/python nolang python27 you will end with a 'uwsgi' binary and 'python33_plugin.so' and 'python27_plugin.so'

Categories : Python

Selenium hanging and timing out on basic page interactions on OWA.
I have seen this happen in my own tests, but on an intermittent basis, and never completely reproducible. What seems to happen is that Selenium WebDriver just becomes blocked and unresponsive. I know that I have just had to resort to rescuing the error, logging, and retrying in my code. After a few retrys, Selenium WebDriver seems to become responsive again and I'm able to continue on in my tests from there. I have contacted the maintainer of the Ruby WebDriver gem, and he needs a reproducible test to be able to do some solid debugging. If you are able to provide a reproducible test case, please share it with us so that we can look into this issue. You can use this gist as a starting point to share with the community.

Categories : Ruby

Python ssl login hanging on Debian
So things look ok on Fedora: [bharrington@leviathan ~]$ python Python 2.7.5 (default, Aug 22 2013, 09:31:58) [GCC 4.8.1 20130603 (Red Hat 4.8.1-1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import mechanize >>> br = mechanize.Browser() >>> br.open("https://wwws.mint.com/login.event") <response_seek_wrapper at 0x29b6440 whose wrapped object = <closeable_response at 0x29b6320 whose fp = <socket._fileobject object at 0x298d150>>> >>> br.title() 'Mint > Start Here' >>> Which leads me to wonder about the SSL/OpenSSL libraries in use. Just to test it out can you run from the command line: $ openssl s_client -connect wwws.mint.com:443 You should see the SSL certificate for mint di

Categories : Python

Python - while loop hanging without errors
Your while loop is not giving the main loop a chance to run. For this reason, once buttonclick_mainscreen calls gamescreen, pressed remains 1 and never changes its value. Any callback called from the event loop must immediately return to the event loop, otherwise the program becomes unresponsive. Instead of staying in the while loop, simply return from gamescreen and do the rest of the work from callbacks that process user events (canvas.bind) and timeouts (canvas.after). Each iteration of the current loop will be one invocation of the callback. It is at first confusing to rewrite algorithms in this way, but that's how event loops work.

Categories : Python

Make footer get pushed off page by content but stay at bottom when not full page content
in your html you have <footer> and css footer{ some-code} shouldn't this be an id (if onyl used once per page) or class (if used multiple times per page)? .footer or #footer then <div id="footer">text</div>

Categories : HTML

Python, running a subprocess and read output and not hanging the program
Here is a very basic implementation of your class running as a new process. This will allow you to continue execution within your main script/process but you will need to use some sort of interprocess communication (ie. a shared memory data structure described in multiprocessing docs) if you want to do anything with the output of the child process within the parent. from sys import * from subprocess import * import multiprocessing class ProcessNAS(multiprocessing.Process): def __init__ (self, name): self.name_ = name self.status = False self.process = None super(ProcessNAS, self).__init__(target=self.StartCheck) def StartCheck(self): print "Checking for NAS..." stdout.flush() self.process = Popen( ["dns-sd", "-B", "_ssh._tc

Categories : Python

ASP.NET Error: Content controls are allowed only in content page that references a master page
The page that you've put the content control is not a master page based page. Check the top of the page, if you've got html like <html> <body> tags then the likelihood is that you've created a new page rather than a new page based off a masterpage.

Categories : Asp Net

Having some IE8 specific loading issues on my page / Hanging at blank screen with "n items remaining" in status bar
I used BrowserStack to test this and I didn't have a problem at all. This could very well be a JavaScript issue. Try minimizing & concatenating your JS & CSS files. You can also create image sprites instead of loading lots of small images. After all that IE will have less files to download and they'll all be smaller so that should help. Also, I see you're using WordPress which is a little harder to set up by try loading your JS at the bottom of the page. That way IE doesn't get hung up on a JS file at the top.

Categories : Wordpress

Printing a Gridview - how to print n rows on each page using page break
CSS page-break-after not working cross browser I tested page-break-after: always; with ie10 and firefox 22 - it works in both; in Chrome 30 it does not work. So its difficult to tell why it does not work for you in firefox 22. If your user base is mostly IE and firefox (like in our company). This will work: .pagebreak { page-break-after: always; } Apparently the support for css pagebreak is not ideal: pagebreak does not work in chrome or pagebreak not working in all browsers A search for chrome issues lead me to issue 99124 - Printed table content does not respect page-break CSS properties; reported on Oct 4, 2011 and still untriaged: Confirmed, not reviewed for priority and assignment. It seems that printing is just not important. Adding this css did not help either: @medi

Categories : Javascript

Mixed content error when proxying websocket through nginx with SSL
Change match original protocol to match origin protocol: io.configure(function() { //io.set('match original protocol', true); io.set('match origin protocol', true); ... }

Categories : Node Js

Printing the content of an Array in PHP
Use print_r($greetings); instead of echo $greetings;//Echo is used to display string. For more check the documenation print_r echo

Categories : PHP

Grid not printing content
maybe this question will help you. You can look at the Measure and Arrange methods, probably smth in there. Print Grid which generated dynamically in wpf

Categories : C#

Printing the content of array slots in c#
i guess you want to write all the information in array. for that you need to use a loop like this for(int i=0;i<Säljkår.Length;i++) { Console.WriteLine("Namn: " + Säljkår[i].Namn); Console.WriteLine("Personnummer: " + Säljkår[i].Personnummer); Console.WriteLine("Distrikt: " + Säljkår[i].Distrikt); Console.WriteLine("Antal sälj: " + Säljkår[i].AntalArtiklar); Console.WriteLine("Sälj Nivå: " + Säljkår[i].Niva); Console.WriteLine("-----------------------------"); }

Categories : C#

PDFkit ignore footer?
Have you tried adding css specifically for the print media type and setting the footer to not display? Something like: @media print { #footer { display: none; } }

Categories : Ruby On Rails

Printing the content of each subarray on individual lines
I hope this will help you $array = array ( array( 0.999999, 5.65423e-007, 2.3301e-008 ), array ( 0.333333, 0.333333, 0.333333 ), array ( 1.19172e-007, 0.999993, 6.75659e-006 ) ); foreach($array as $item) print_r(implode(" ", $item)." ");

Categories : PHP

Nginx not redirecting to 404 page
First of all I'd suggest changing the index rule, bring up the index.php in the beginning, right now you don't have any php handling engine in the config, do you have fastcgi or fpm installed on the server? change index index.html index.htm index.php; to index index.php index.html; after determining which php engine you have I can tell you which lines to uncomment, right now without the php engine nginx should server the php as a normal file, either print it's data on the browser or prompt you to download the php file.

Categories : Linux

generating pdf hangs on rails 4 using PDFkit gem
The issue was due to stylesheet_link_tag and javascript_include_tag using relative URLs, which often causes wkhtmltopdf to hang when loading assets from the same server that wkhtmltopdf is running on. Using absolute URLs for assets solved the problem. Set asset_host in Rails' config, which also affects stylesheet_link_tag and javascript_include_tag: # Modify asset host config setting in `config/application.rb` # Or create a new initializer: `config/initializers/wkhtmltopdf.rb` config.action_controller.asset_host = "http://mysite.com" # Or you can have different hosts for development (local) and production (CDN): # In `config/environments/development.rb` config.action_controller.asset_host = "http://localhost" # In `config/environments/production.rb` config.action_controller.asset_host

Categories : Ruby On Rails

Node.js: PDFkit write to response
Assuming res is your server response object, just do this: doc.output(function(string) { res.end(string); }); This will send a string representation of the PDF rather than writing it to file. The code above is the compiled CoffeeScript that was in the documentation for PDFKit. doc.output (string) -> console.log string

Categories : Javascript

Rails PDFKit Appearance Bug with Bootstrap
In desperation I went to the Bootstrap Customise page (http://getbootstrap.com/customize/?id=6470483) and re-downloaded the files and used the non-minified version in my pdf.css and it seems to work fine. I only ticked the top five check boxes in the first column: Print media styles Typography Code Grid system Tables

Categories : Ruby On Rails

Reading a file using fgets and printing its content on screen
Try some parentheses: if((result=fgets(line,MAX_LENGTH,fp)) != NULL) ^ ^ Without those you'll store the result of the comparison instead of a pointer to the string. Side note: you don't need result at all. When it succeeds, fgets returns the pointer you passed in; in other words you can just printf line: if(fgets(line, MAX_LENGTH, fp)) printf("The string is %s ", line); Second side note: before trying to fgets from the file, you should check whether fopen succeeded: if (!fp) perror("fopen");

Categories : C

Closest approximation to Python 2 style printing in python 3
That is still valid syntax in python 3, but print is no longer a statement. It is a function, so you must put parentheses: print("%s" % x)

Categories : Python

How to use Nginx to redirect to specific page?
add in your t.example.com location { } something like: rewrite ^(.*) http://testing.example.com/test/$1 permanent; or just simple redirect return 301 http://testing.example.com/test/;

Categories : PHP

How to: nodejs pdfkit output japanese or chinese
PDFKit supports embedding font files in the TrueType (.ttf), TrueType Collection (.ttc), and Datafork TrueType (.dfont) formats. (source: http://pdfkit.org/docs/text.html#fonts) Download a Japanese Font in TrueType (.ttf) format here http://www.freejapanesefont.com/ipaex-gothic/ # Using a TrueType font (.ttf) doc.font('fonts/ipaexg.ttf').text('武大郎')

Categories : Node Js

How to: output Euro symbol in pdfkit for nodejs
Turns out it is a font issue: unicode works, but you have to make sure that the font you are using includes the characters you want to use. Unlike your operating system, PDFKit does not do any automatic font substitution. Source: Reddit Thread comment by /u/devongovett I tested two fonts that were included with pdfkit. Both 'Helvetica-Bold' and 'Times-Roman' didn't work with the unicode symbols. I noticed in the documentation for fonts that you can add in your own fonts, so I gave the Cardo Font (hosted on Google Fonts) a go as it supports many unicode characters. Sure enough, it worked. Here is the script I used for testing (Make sure you have the Cardo font available): var PDFDocument = require('pdfkit'); var doc = new PDFDocument(); doc.registerFont('Cardo', 'Cardo/Cardo

Categories : Node Js



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.