I had setup a simple Django project in hostmonster:
The project name is thep_viet, the app is mainapp
my .htaccess is
AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ django.fcgi/$1 [QSA,L]
my django.fcgi is
#!/usr/bin/env python
# -*- mode: python; -*-
import sys, os
# Add a custom Python path.
sys.path.insert(0, "/home/riasolut/django/django_projects/")
# Switch to the directory of your project. (Optional.)
#os.chdir("/home/riasolut/django/django_projects/thep_viet")
# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "thep_viet.settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
I'm setting python 2.7.2 and django 1.3.1 succesfully
I'm create a folder named thep_viet in ~/django/django_projects/. This folder contain all source code of thep_viet project.
I'm create a folder named thep_viet in public_html and place .htaccess and django.fcgi in this.
When I'm running django.fcgi by command line:
python ~/public_html/thep_viet/django.fcgi
I receive the result:
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Status: 200 OK
Content-Type: text/html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="robots" content="NONE,NOARCHIVE"><title>Welcome to Django</title>
<style type="text/css">
html * { padding:0; margin:0; }
body * { padding:10px 20px; }
body * * { padding:0; }
body { font:small sans-serif; }
body>div { border-bottom:1px solid #ddd; }
h1 { font-weight:normal; }
h2 { margin-bottom:.8em; }
h2 span { font-size:80%; color:#666; font-weight:normal; }
h3 { margin:1em 0 .5em 0; }
h4 { margin:0 0 .5em 0; font-weight: normal; }
table { border:1px solid #ccc; border-collapse: collapse; width:100%; background:white; }
tbody td, tbody th { vertical-align:top; padding:2px 3px; }
thead th { padding:1px 6px 1px 3px; background:#fefefe; text-align:left; font-weight:normal; font-size:11px; border:1px solid #ddd; }
tbody th { width:12em; text-align:right; color:#666; padding-right:.5em; }
ul { margin-left: 2em; margin-top: 1em; }
#summary { background: #e0ebff; }
#summary h2 { font-weight: normal; color: #666; }
#explanation { background:#eee; }
#instructions { background:#f6f6f6; }
#summary table { border:none; background:transparent; }
</style>
</head>
<body>
<div id="summary">
<h1>It worked!</h1>
<h2>Congratulations on your first Django-powered page.</h2>
</div>
<div id="instructions">
<p>Of course, you haven't actually done any work yet. Here's what to do next:</p>
<ul>
<li>If you plan to use a database, edit the <code>DATABASES</code> setting in <code>thep_viet/settings.py</code>.</li>
<li>Start your first app by running <code>python thep_viet/manage.py startapp [appname]</code>.</li>
</ul>
</div>
<div id="explanation">
<p>
You're seeing this message because you have <code>DEBUG = True</code> in your
Django settings file and you haven't configured any URLs. Get to work!
</p>
</div>
</body></html>
It seem django can run effectly
But when I'm running in browser:
thepviet.mydomain.com
with thepviet.mydomain.com point to mydomain.com/thep_viet
I receive the 500 error:
<!-- SHTML Wrapper - 500 Server Error -->
[an error occurred while processing this directive]
Did I forget any thing? I thing something wrong in config fastcgi in apache of hostmonster.
Please help my problem.
I've read the error log and found:
[Fri Nov 18 19:50:04 2011] [warn] [client 113.185.2.152] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Fri Nov 18 19:50:04 2011] [error] [client 113.185.2.152] Premature end of script headers: django.fcgi
[Fri Nov 18 19:50:04 2011] [error] [client 113.185.2.152] invalid CGI ref "/500.php" in /home4/riasolut/public_html/500.shtml
Is this error belong to the FastCGI server or my code?
You have a syntax error in your fcgi file:
runfastcgi(method="threaded", "daemonize="false")
The quote mark before daemonize shouldn't be there.
As Jack M says in the comment, if you'd looked in the server error log, you would almost certainly see the error there.
Related
I am trying to run cloud_sql_proxy installed as a binary from go get, but I always get a 404 Error.
I have followed the instructions at https://github.com/GoogleCloudPlatform/cloudsql-proxy, but with no luck.
$GOPATH/go/bin/cloud_sql_proxy -instances=project_name:region:instance_name=tcp:3306 -credential_file=/path/to/cloud-sql-proxy.json
The error I get:
2020/01/18 13:20:03 Rlimits for file descriptors set to {&{8500 9223372036854775807}}
2020/01/18 13:20:03 using credential file for authentication; email=<EMAIL>
2020/01/18 13:20:03 errors parsing config:
googleapi: got HTTP response code 404 with body: <!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 404 (Not Found)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}#media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}#media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}#media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>404.</b> <ins>That’s an error.</ins>
<p>The requested URL <code>/sql/v1beta4/sql/v1beta4/projects/project_name/instances/instance_name?alt=json&prettyPrint=false</code> was not found on this server. <ins>That’s all we know.</ins>
However, if I get the binary from https://cloud.google.com/sql/docs/mysql/sql-proxy, then the connection if fine, proving that the instance address and the credential file work just fine. The service account has also the Cloud SQL Admin role, so that should be just fine as well.
I have cloned the repo, and tried to debug the code to see where exactly if fails, and of course, it fails at:
cmd/cloud_sql_proxy/proxy.go:268
sql.BasePath = *host
inst, err := sql.Instances.Get(proj, name).Do()
if err != nil {
return instanceConfig{}, err
}
The reason I am insisting on using the go-binary is that I want to re-use cloud_sql_proxy on Raspberry PI 3b+, and this seems to be the only option of getting cloud_sql_proxy working on ARM architecture.
I've made a project that using flask_socketio extension for user notifications and i want to deploy it on server .
I've already finished reading the Flask-SocketIO documentation and just did everything literally in Deployment section.
Now if i run the application at the beginning everything works fine, inside the console i've just logged a message if user logged in that says User Connected! just to make sure it work .
Now, i am logged in and the site works just fine, but if i want to navigate the other pages of the site it hangouts for a while lets say 30s and it logs me out .
Here is some code snippets:
base.html the base is extended for all pages
<script type="text/javascript">
var socket = io.connect('http://' + document.domain + ':' + location.port + '/notifications-{{session.get("client_logged_in")}}-{{session.get("client_family")}}');
var appointments_received = [];
socket.on('connect', function(){
console.log('User Connected!');
});
socket.on('new_message', function(msgChat){
$('<li class="notification">\
<div class="notification_client_ava_border">\
{% if '+msgChat.image+' %}\
<img src="/static/img/'+msgChat.image+'" alt="myproject" class="notification_client_ava">\
{% else %}\
<img src="/static/img/main.png" alt="myproject" class="notification_client_ava">\
{% endif %}\
</div>\
<div class="notification_info">\
<div class="client_info">\
<p class="user_name">\
You have new message from: '+msgChat.from+'\
'+shortName+'\
</p>\
</div>\
<br>\
<div class="service_info">\
{% if '+actionArray[0] == +' "Message:" %}\
<span>'+msgChat.message+'</span></br>\
{% endif %}\
</div>\
<br><br>\
<div class="">\
<span class="date">\
'+moment().fromNow()+'\
</span>\
</div>\
</div>\
<div class="notification_action">\
<a href="/user/cat-{{g.current_directory}}/chat/'+msgChat.to_url_+'?current_user={{session.get("client_logged_in")}}+{{session.get("client_family")}}" id="noty_read" class="btn btn-primary btn-block" data-get='+msgChat.noty_id+'>read it</a>\
</div>\
</li>'
).appendTo('ul#messages_list');
});
</script>
myapp.service here the Gunicorn instance to serve my project inside system directory
[Unit]
Description=Gunicorn
After=network.target
[Service]
User=gard
WorkingDirectory=/home/gard/myproject
Environment="PATH=/home/gard/myproject/venv/bin"
ExecStart=/home/gard/myproject/venv/bin/gunicorn --bind 0.0.0.0:5000 manage:app
[Install]
WantedBy=multi-user.target
Here is also my project config file the Nginx using to serve my project:
server {
listen 80;
server_name 123.45.678.901;
location / {
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://127.0.0.1:5000;
break;
}
}
location /socket.io {
include proxy_params;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass http://127.0.0.1:5000/socket.io;
}
}
Here all my codes that i can provide and i repeat , the site work just fine and i can see the User Connected! message inside the console when user logs in my home page , but if i want to navigate another pages the hangs happens and it logs me out of site .
I forgot to show the error that i indeed up with inside the console :
http://123.45.678.901/socket.io/?EIO=3&transport=polling&t=LtFziAg&sid=636e939b538f4b0ca6df5cd521c2e187 400 (BAD REQUEST)
The problem is solved , i must define which async_mode to use inside the SocketIO structure .
Flask-SocketIO by default gives the first choice for Eventlet , the second choice goes to Gevent , for more information read this issues/294
To resolve this kind of problem just add this to your code :
socketio = SocketIO(async_mode='gevent')
I have a problem in app rails.
My app works fine on the development server, but on my host it does not work when uploading, and throws me this error on any path of my application.
I checked all the drivers to see if there are any closures, but I did not find anything unusual.
Here I show my log production.
I, [2017-07-06T02:47:57.031902 #30638] INFO -- : Started GET "/" for 187.204.162.35 at 2017-07-06 02:47:57 +0200
I, [2017-07-06T02:47:57.046063 #30638] INFO -- : Processing by WelcomeController#index as HTML
I, [2017-07-06T02:47:57.608254 #30638] INFO -- : Rendered welcome/index.html.erb within layouts/application (535.1ms)
I, [2017-07-06T02:47:57.608542 #30638] INFO -- : Completed 500 Internal Server Error in 562ms (ActiveRecord: 0.0ms)
F, [2017-07-06T02:47:57.610259 #30638] FATAL -- :
ActionView::Template::Error (SyntaxError: Unexpected token: keyword (else)):
130: <div class="row">
131:
132: <div class="col-md-4">
133: <%= image_tag("mision.png", :style => "width: 50px; margin: auto; display: block;", class: "img-responsive") %>
134: <h3 class="text-center" style="color: #004467;"><strong>MISIÓN</strong></h3>
135: <p style=" text-align: justify;">Hacer realidad los sueños de nuestros clientes Lo logramos con: propuestas y soluciones claras, asesoría persona$
136: </div>
app/views/welcome/index.html.erb:133:in `_app_views_welcome_index_html_erb___3018899638396619987_70193610437540'
I'm under Apache + fastCGI with Django 1.8
My folder on the shared host looks like:
/home/username/
/home/username/MyProject_SRC
/home/username/MyProject_SRC/MyProject/manage.py
and:
/home/username/public_html/.htaccess
/home/username/public_html/index.fcgi
I've edited .htaccess and index.fcgi to look like this:
.htaccess :
AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_URI} !=/index.fcgi
RewriteRule ^(.*)$ index.fcgi/$1 [QSA,L]
index.fcgi:
#!/home/username/djangoenv/bin/python3
import sys, os
sys.path.insert(0, "/home/username/MyProject_SRC")
os.chdir("/home/username/MyProject_SRC")
os.environ['DJANGO_SETTINGS_MODULE'] = "MyProject.settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
Now, when I do on the server:
(djangoenv)username#hostname [~/public_html]# ./index.fcgi
Status: 200 OK
Vary: Cookie
X-Frame-Options: SAMEORIGIN
Content-Type: text/html; charset=utf-8
<!DOCTYPE html>
<html lang="en">
.... // Normal webpage
</html>
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Going on my Home webpage returns a 500 internal error without more in the logs.
EDIT I've got the same result when doing:
(djangoenv)username#hostname [~/MyProject_SRC]# ./manage.py runfcgi
I had a similar problem, in my case I did not find a specific source, but I tried to add this in my index.fcgi and doing ./index.fcgi no longer asked me, if it keeps getting 500 check the version of flup you are using, which be 1.0.2 preferably.
os.environ['REQUEST_METHOD'] = "GET"
os.environ['SERVER_NAME'] = "yourdomain.com"
os.environ['SERVER_PORT'] = "80"
os.environ['SERVER_PROTOCOL'] = "HTTP/1.1"
I'm trying to get Orbited running as per instructions on http://mischneider.net/?p=125
Here's a copy of the error:
Validating models...
0 errors found
Django version 1.3, using settings 'comet.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[28/May/2011 11:43:36] "GET /comet/ HTTP/1.1" 200 2952
[28/May/2011 11:43:36] "GET /site_media/Orbited.js HTTP/1.1" 304 0
[28/May/2011 11:43:37] "GET /site_media/stomp.js HTTP/1.1" 304 0
[28/May/2011 11:44:18] "POST /addMessage/ HTTP/1.1" 403 2332
[28/May/2011 11:44:21] "POST /addMessage/ HTTP/1.1" 403 2332
[28/May/2011 11:44:40] "GET /comet/ HTTP/1.1" 200 2952
[28/May/2011 11:44:41] "GET /site_media/Orbited.js HTTP/1.1" 304 0
[28/May/2011 11:44:41] "GET /site_media/stomp.js HTTP/1.1" 304 0
No handlers could be found for logger "stomp.py"
[28/May/2011 12:00:36] "GET /comet/ HTTP/1.1" 200 2952
Also, when I load the page it gives me an error. Here's a selection of some of my files.
index.html:
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Django, Orbited, Stomp and Co.</title>
<script src="http://www.json.org/json2.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="/site_media/Orbited.js"></script>
<script>
// set the orbited settings and port
Orbited.settings.port = 9000;
Orbited.settings.hostname = "127.0.0.1";
//Orbited.settings.streaming = false;
TCPSocket = Orbited.TCPSocket
</script>
<script> document.domain = document.domain; </script>
<script src="/site_media/stomp.js"></script>
<script type="text/javascript" charset="utf-8">
function add_message(msg) {
$("<p>" + msg["user"] + ": " + msg["message"] + " at " + msg["time"] + "</p>").appendTo("#messages")
};
$(document).ready(function() {
stomp = new STOMPClient();
stomp.onopen = function(){
//console.log("opening stomp client");
};
stomp.onclose = function(c){
alert('Lost Connection, Code: ' + c);
};
stomp.onerror = function(error){
alert("Error: " + error);
};
stomp.onerrorframe = function(frame){
alert("Error: " + frame.body);
};
stomp.onconnectedframe = function(){
console.log("Connected. Subscribing");
//alert("subscribing");
stomp.subscribe("/messages");
};
stomp.onmessageframe = function(frame){
// Presumably we should only receive message frames with the
// destination "/topic/message" because that's the only destination
// to which we've subscribed. To handle multiple destinations we
// would have to check frame.headers.destination.
add_message(JSON.parse(frame.body));
};
stomp.connect('localhost', 61613);
$("#send").click(function(data) {
var message = $("#message").val()
var user = $("#user").val()
$.post("/addMessage/", {"message":message, "user":user});
})
});
</script>
</head>
<body id="index">
<div id="messages">
{% for message in messages %}
<p>{{message.user}}: {{message.body}} at {{message.time|date:"H:i-d/m/Y"}}</p>
{% endfor %}
</div>
<div id="new_message">
Text: <input type="text" name="message" value="" id="message"> Name: <input type="text" name="user" value="" id="user">
<p><button type="text" id="send" value="Submit a message">Submit a message</button><p>
</div>
</body>
orbited.cnf
[listen]
http://:9000
stomp://:61613
[access]
* -> localhost:61613
[global]
session.ping_interval = 300
# new logging configuration using the python stdlib logging.fileConfig
[loggers]
keys = root,orbited,orbited_TCPConnectionResource
[handlers]
keys = console,errors,connections
[formatters]
keys = generic
[logger_root]
level = INFO
handlers = console
[logger_orbited]
level = INFO
handlers = errors
qualname = orbited
[logger_orbited_TCPConnectionResource]
level = DEBUG
handlers = connections
qualname = orbited.cometsession.TCPConnectionResource
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = INFO
formatter = generic
[handler_errors]
class = FileHandler
args = ('error.log', 'w')
level = INFO
formatter = generic
[handler_connections]
class = FileHandler
level = DEBUG
formatter = generic
args = ('connections.log', 'w')
[formatter_generic]
format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
urls:
from django.conf.urls.defaults import patterns, include, url
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
from django.conf.urls.defaults import *
from stompapp.views import *
urlpatterns = patterns('',
(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': 'C:/Users/Hunter/DjangoBackup/comet/static'}),
(r'^comet/', index),
(r'^addMessage/', addMessage),
(r'^site_media/(.*)$', 'django.views.static.serve', {'document_root': 'PATH_TO_YOUR_STATIC_FOLDER'}),
)
I hope my problem is somewhere in there? Thanks for the help :D
Also, when I load the page it gives me an error.
What exactly error? I guess you are talking something else than "No handlers could be found for logger "stomp.py"" message?