beta_settings:
cloud_sql_instances: eco-income:europe-west3:ecoincome-postgres
runtime: python
env: flex
manual_scaling:
instances: 1
resources:
cpu: 0.2
memory_gb: 0.5
disk_size_gb: 10
health_check:
enable_health_check: False
runtime_config:
python_version: 3
entrypoint: web/run.sh
env_variables:
SECRET_KEY: '___DJANGO_SECRET_KEY___'
DEBUG: 'True' # always False for deployment
SMTP_HOST: "___SMTP_HOST___"
SMTP_USER: "___SMTP_USER___"
SMTP_PASSWORD: "___SMTP_PASSWORD___"
DB_HOST: '/cloudsql/.........................'
DB_PORT: '5432' # PostgreSQL port
DB_NAME: '......'
DB_USER: '........'
DB_PASSWORD: '___DB_PASSWORD___'
STATIC_URL: 'https://storage.googleapis.com/................-backend-static-files/static/' # this is the url that you sync static files to
handlers:
- url: /.*
script: auto
secure: always
beta_settings:
cloud_sql_instances: .....................
runtime: python37
entrypoint: web/run.sh
env_variables:
SECRET_KEY: '___DJANGO_SECRET_KEY___'
DEBUG: 'True' # always False for deployment
SMTP_HOST: "___SMTP_HOST___"
SMTP_USER: "___SMTP_USER___"
SMTP_PASSWORD: "___SMTP_PASSWORD___"
DB_HOST: '/cloudsql/.........................' DB_PORT: '5432' # PostgreSQL portDB_NAME: '......'DB_PASSWORD: '___DB_PASSWORD___'
DB_USER: '........'STATIC_URL: 'https://storage.googleapis.com/................-backend-static-files/static/' # this is the url that you sync static files to
beta_settings:cloud_sql_instances: .....................
import osimport sysweb_dir = (os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir)))src_dir = (os.path.abspath(os.path.join(web_dir, os.pardir)))lib_dir = os.path.join(src_dir, "lib")sys.path.append(lib_dir)# Build paths inside the project like this: os.path.join(BASE_DIR, ...)BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))# Quick-start development settings - unsuitable for production# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/# SECURITY WARNING: keep the secret key used in production secret!SECRET_KEY = os.environ['SECRET_KEY']ACME_CHALLENGE_URL_SLUG = ""ACME_CHALLENGE_TEMPLATE_CONTENT = ""# SECURITY WARNING: don't run with debug turned on in production!DEBUG = os.environ['DEBUG'] == 'True'PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))ALLOWED_HOSTS = ['*']# Application definitionINSTALLED_APPS = ['django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','rest_framework','acme_challenge','rest_framework.authtoken','corsheaders','django_countries','rest_registration','apps.users','apps.api_lib',]MIDDLEWARE = ['corsheaders.middleware.CorsMiddleware','django.middleware.security.SecurityMiddleware','django.contrib.sessions.middleware.SessionMiddleware','django.middleware.common.CommonMiddleware','django.middleware.csrf.CsrfViewMiddleware','django.contrib.auth.middleware.AuthenticationMiddleware','django.contrib.messages.middleware.MessageMiddleware','django.middleware.clickjacking.XFrameOptionsMiddleware',]CORS_ORIGIN_WHITELIST = ('...........','localhost:8000','localhost:4200')ROOT_URLCONF = 'app.urls'TEMPLATES = [{'BACKEND': 'django.template.backends.django.DjangoTemplates','DIRS': [],'APP_DIRS': True,'OPTIONS': {'context_processors': ['django.template.context_processors.debug','django.template.context_processors.request','django.contrib.auth.context_processors.auth','django.contrib.messages.context_processors.messages',],},},]WSGI_APPLICATION = 'app.wsgi.application'DATABASES = {'default': {'ENGINE': 'django.db.backends.postgresql','HOST': os.environ['DB_HOST'],'PORT': os.environ['DB_PORT'],'NAME': os.environ['DB_NAME'],'USER': os.environ['DB_USER'],'PASSWORD': os.environ['DB_PASSWORD'] or ''}}AUTH_PASSWORD_VALIDATORS = [{'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',},{'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',},{'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',},{'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',},]LANGUAGE_CODE = 'en-us'TIME_ZONE = 'UTC'USE_I18N = TrueUSE_L10N = TrueUSE_TZ = True# Static files (CSS, JavaScript, Images)# https://docs.djangoproject.com/en/1.11/howto/static-files/STATIC_URL = os.environ['STATIC_URL'] # /static/ if DEBUG else Google Cloud bucket url# collectstatic directory (located OUTSIDE the base directory)# TODO: configure the name and path to your static bucket directory (where collectstatic will copy to)STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), '..................')STATICFILES_DIRS = [# TODO: configure the name and path to your development static directoryos.path.join(BASE_DIR, 'static'), # static directory (in the top level directory) for local testing]PASSWORD_HASHERS = ['django.contrib.auth.hashers.PBKDF2PasswordHasher','django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher','django.contrib.auth.hashers.Argon2PasswordHasher','django.contrib.auth.hashers.BCryptSHA256PasswordHasher',]REST_FRAMEWORK = {'DEFAULT_AUTHENTICATION_CLASSES': ('rest_framework.authentication.TokenAuthentication',),}REST_FRAMEWORK_TOKEN_EXPIRE_HOURS = 24AUTH_USER_MODEL = "users.user"REST_REGISTRATION = {'REGISTER_VERIFICATION_URL': 'https://www............/verify-user/','RESET_PASSWORD_VERIFICATION_URL': 'https://www.........../reset-password/','REGISTER_EMAIL_VERIFICATION_URL': 'https://www............/verify-email/','VERIFICATION_FROM_EMAIL': 'no-reply@...........',}EMAIL_HOST = os.environ['SMTP_HOST']EMAIL_HOST_USER = os.environ['SMTP_USER']EMAIL_HOST_PASSWORD = os.environ['SMTP_PASSWORD']APPEND_SLASH = True
web_dir = (os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir)))
src_dir = (os.path.abspath(os.path.join(web_dir, os.pardir)))
lib_dir = os.path.join(src_dir, "lib")
"""
"""
sys.path.append(lib_dir)
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ['SECRET_KEY']
ACME_CHALLENGE_URL_SLUG = ""
ACME_CHALLENGE_TEMPLATE_CONTENT = "" \
"."
'......',
'......',
'localhost:8000',
'localhost:4200'
)
ROOT_URLCONF = 'app.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'app.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'HOST': os.environ['DB_HOST'],
'PORT': os.environ['DB_PORT'],
'NAME': os.environ['DB_NAME'],
'USER': os.environ['DB_USER'],
'PASSWORD': os.environ['DB_PASSWORD'] or ''
}
}
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = os.environ['STATIC_URL'] # /static/ if DEBUG else Google Cloud bucket url
# collectstatic directory (located OUTSIDE the base directory)
# TODO: configure the name and path to your static bucket directory (where collectstatic will copy to)
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), '......')
STATICFILES_DIRS = [
# TODO: configure the name and path to your development static directory
os.path.join(BASE_DIR, 'static'), # static directory (in the top level directory) for local testing
]
PASSWORD_HASHERS = [
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
'django.contrib.auth.hashers.Argon2PasswordHasher',
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
]
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
),
}
REST_FRAMEWORK_TOKEN_EXPIRE_HOURS = 24
AUTH_USER_MODEL = "users.user"
REST_REGISTRATION = {
'REGISTER_VERIFICATION_URL': 'https://www.....verify-user/',
'RESET_PASSWORD_VERIFICATION_URL': 'https://www......./reset-password/',
'REGISTER_EMAIL_VERIFICATION_URL': 'https://www....../verify-email/',
'VERIFICATION_FROM_EMAIL': 'no-reply@......',
}
EMAIL_HOST = os.environ['SMTP_HOST']
EMAIL_HOST_USER = os.environ['SMTP_USER']
EMAIL_HOST_PASSWORD = os.environ['SMTP_PASSWORD']
APPEND_SLASH = True
I have a Django application with Google Cloud SQL Postgres Database deployed to App Engine Flex at the moment.I am trying to migrate it from Flex to Standard.Everything seems to work, except the Database connection. The Documentation is not quite clear about it.For Flex I need to use:
beta_settings:
cloud_sql_instances: .......
runtime: python37
entrypoint: web/run.sh
env_variables:
SECRET_KEY: '___DJANGO_SECRET_KEY___'
DEBUG: 'True'
SPECTRE_APP_ID: "___SPECTRE_APP_ID___"
SPECTRE_APP_SECRET: "___SPECTRE_APP_SECRET___"
MAILCHIMP_KEY: "___MAILCHIMP_KEY___"
SMTP_HOST: "___SMTP_HOST___"
SMTP_USER: "___SMTP_USER___"
SMTP_PASSWORD: "___SMTP_PASSWORD___"
DB_HOST: '/cloudsql/<project>:<region>:<db>'
DB_NAME: '....'
DB_USER: '....'
DB_PASSWORD: '___DB_PASSWORD___'
STATIC_URL: 'https://storage.googleapis.com/.....-backend-static-files/static/'
beta_settings:
cloud_sql_instances: <project>:<region>:<db>
could not connect to server: Connection refused
Is the server running locally and accepting
connections on Unix domain socket "/cloudsql/<project>:<region>:<db>/.s.PGSQL.5432"?
--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/dfe47469-a29f-4382-b54a-c730bb1cde12%40googlegroups.com.
class Variables(View):
def get(self, request):
data = {}
try:
data["cloudsql"] = os.listdir('/cloudsql')
except Exception as e:
data["cloudsql"] = str(e)
return JsonResponse(data)
{"cloudsql": []}
Hello,
I can see that you have already created an Issue Tracker (117804657) for this issue and that has been sent to Cloud SQL Engineering team for further investigation and they will update the progress on the issue tracker[1].
Please kindly note that, we cannot offer an ETA for a resolution at this time.
[1] https://issuetracker.google.com/117804657