I have a Google App Engine app and I'm running Windows with Vagrant. I have an Ubuntu installation which I access via vagrant ssh. On that machine I installed the Google App Engine SDK for Python and I can successfully deploy my app with:
appcfg.py update myapp --oauth2 --noauth_local_webserver
The --noauth_local_parameter allows me to copy the oauth URL and paste in the browser on my Windows machine, because on the Linux machine I have no GUI. Everything is working fine.
But now I want to use the Django manage.py syncdb command, to create the tables in Google Cloud SQL. The problem is, when I execute that command, the text-based w3n browser starts for the authorization, and then I get the error message that the browser does not support javascript.
I'd like to run the manage.py commands with the --noauth_local_webserver flag, but that is not supported by the manage.py commands. How can I solve this? I have already installed an Ubuntu virtual machine with GUI and given the app the permission and manage.py works fine on that machine, but when I try to execute the command on the Vagrant (non GUI) machine, it stills want to open the browser for permission.
Hm, I manually copied the oauth .dat file to the vagrant server, and manage.py syncdb is now working, but the website still can't connect in the browser; it says:
No valid OAuth 2.0 credentials. Before using the Google SQL Service backend on dev_appserver, you must first run "manage.py syncdb" and proceed through the given instructions to fetch an OAuth 2.0 token.
It seems to be the same errors as here. In my case it seemed that the necessary GOOGLE_SQL_OAUTH2_REFRESH_TOKEN environment variable was not set. I copied this refresh token from the .dat file and set it in the app.yaml:
env_variables:
GOOGLE_SQL_OAUTH2_REFRESH_TOKEN: "..."
Now everything is working fine.
Related
I have an application that should run via VPS terminal-based so that the web app can be online permanently.
The command: python manage.py runserver 173.249.8.237:8000 should be executed via the VPS terminal because when I use putty via my laptop, whenever I switch off my putty software via my laptop, the application won't be accessible.
Please, suggest to me a way open a terminal in order to run the Django application server.
Or, is there any method that can allow me to my Django web application on VPS?
Thanks in advence
Don't do that.
runserver according Django Docs
DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone
through security audits or performance tests. (And that’s how it’s
gonna stay. We’re in the business of making web frameworks, not web
servers, so improving this server to be able to handle a production
environment is outside the scope of Django.)
You need to configure your Django application to run in production environments. You change choose docker for that.
Or simple running with gunicorn.
Access your VPS through SSH or Putty.
Copy your application code inside VPS
Configure your application to run with gunicorn or docker
Access your VPS address in your browser.
And turn of the DEBUG mode, by setting DEBUG=False
I have a Django app that I am trying to deploy to AWS.
I need two command lines to run the app. One command line will be used to runserver and another one to run a background task. That is how the app runs in my localserver.
How do I start two command lines in AWS?
As i can understand your django app is currently in development mode, I've used tmux for development mode, this page will guide you better to use tmux. Once you have started a tmux session run python3 manage.py runserver and then detach to the session using ctrl-b then press d and now your app will run even after you exit the shell.
To know more about tmux go through this page.
In case you have to run your app in production mode Don't use above method, run your app with any of nginx or apache2 server. This tutorial can guide you to set up your django app with nginx and gunicorn.
Supervisor is a good way to control that. You can run a lot of processes (like server, migration, collectstatic, Celery) easily.
Additionally, you can ensure that all processes will run again when your machine reboots.
And, as everybody said, you have to install a server in production that supports WSGI in order to run Django properly.
I'm using Pycharm Professional edition to maintain a Django web application hosted on a remote Linux OS. Until now I've used Expandrive to mount the remote volume as a local windows mapped drive and can use remote debugging.
However I would like to develop locally and deploy to the server which I've got working but struggling to configure the run/debug configuration in conjunction with the Django settings in preferences considering I use supervisor to control all the processes.
Here's a screenshot of my deployment configuration (connection)
Here's a screenshot of my deployment configuration (mappings)
Here's a screenshot of run/debug configuration
When I enable django support, point to my manage.py script and run the configuration it tries to run using manage.py whereas I want it to use the supervisor script. So I therefore get this:
However the real problem is I would like to control the remote supervisor from pycharm
I have a batch File that runs Django Server and it works perfect.
c:\Python27\python.exe manage.py runserver 8003
and that I am using a 3rd Party app NSSM https://nssm.cc/
Which run my Batch file as a Windows Service.
the point is the Service does not start the Server. How can I run the server using this service; the service will open the cmd and execute the command.
Should I use another 3rd party app or is there any command that I can add to my batch file and update it the serive
If you want to run django as a Windows service for development purposes (see the comment above), I have had good luck with instsrv and srvany, both Windows tools that work on all Windows platforms. See https://www.iceflatline.com/2015/12/run-a-windows-application-as-a-service-with-srvany/ for details.
I've followed all steps required to configure Django with GAE + Google Cloud SQL (on Windows 7) but I am unable to authenticate (OAuth2) and run syncdb remotely. When I run manage.py syncdb the browser pops up and I am requested to allow access, but when I do that nothing happens. The browser is forwarded correctly to my local django instalation (the typical It worked! screen) but no OAuth2 token is in %USERPROFILE%\ and the console gets frozen:
C:\Users\me\myproject>python manage.py syncdb
Your browser has been opened to visit:
https://accounts.google.com/o/oauth2/auth?state=None&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&response_type=code&client_id=my_id.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fsqlservice&access_type=offline
If your browser is on a different machine then exit and re-run this
application with the command-line parameter
--noauth_local_webserver
There is no error message and I have to kill the console.
Anybody has faced a similar issue? Is there any log somewhere in GAE I can check?
I had the same problem, only on OS X.
I never figured out why, but it went away after a reboot.
I had the same issue, but it was because I had local appengine server running while I was running manage.py syncdb. Shutting it down and trying again worked as intended.
hope that helps.