Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
A
Aspava
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
Aspava
Commits
c7eab392
Kaydet (Commit)
c7eab392
authored
May 11, 2019
tarafından
Batuhan Taşkaya
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
better quiting and container cleaning, cronjobs
üst
7ee354f0
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
91 additions
and
51 deletions
+91
-51
Pipfile
Pipfile
+1
-0
Pipfile.lock
Pipfile.lock
+14
-1
settings.py
aspava/settings.py
+47
-42
urls.py
aspava/urls.py
+2
-2
manage.py
manage.py
+2
-5
__init__.py
social/cronjobs/__init__.py
+1
-0
renew_evality.py
social/cronjobs/renew_evality.py
+11
-0
__init__.py
social/utils/__init__.py
+1
-0
quitter.py
social/utils/quitter.py
+10
-0
__init__.py
social/views/__init__.py
+2
-1
No files found.
Pipfile
Dosyayı görüntüle @
c7eab392
...
...
@@ -15,6 +15,7 @@ gunicorn = "*"
whitenoise = "*"
docker = "*"
evality = "==0.2.1"
django-cron = "*"
[scripts]
start = "gunicorn aspava.wsgi:application --bind localhost:8000"
...
...
Pipfile.lock
Dosyayı görüntüle @
c7eab392
{
"_meta": {
"hash": {
"sha256": "
f7d5f6bc4fbca2893bd56d1a4941e33a77186a659547c40ffcc69188771f1deb
"
"sha256": "
99500a84e640f527b14abf69b834ae7c8dc17600ae81655272680cf080d79540
"
},
"pipfile-spec": 6,
"requires": {
...
...
@@ -53,6 +53,19 @@
"index": "pypi",
"version": "==0.0.8"
},
"django-common-helpers": {
"hashes": [
"sha256:2d56be6fa261d829a6a224f189bf276267b9082a17d613fe5f015dd4d65c17b4"
],
"version": "==0.9.2"
},
"django-cron": {
"hashes": [
"sha256:08d22708c8b2ecab8cda989019a66c7e1e2424c59d822796fd45abf7731d261d"
],
"index": "pypi",
"version": "==0.5.1"
},
"django-ranged-response": {
"hashes": [
"sha256:f71fff352a37316b9bead717fc76e4ddd6c9b99c4680cdf4783b9755af1cf985"
...
...
aspava/settings.py
Dosyayı görüntüle @
c7eab392
...
...
@@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/2.0/ref/settings/
"""
import
os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
...
...
@@ -19,7 +20,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY
=
'e+4_$yoyv)m*_xs!secifabey&he#18p&e_n06=
%7
qdu
%2
)8!4'
SECRET_KEY
=
"e+4_$yoyv)m*_xs!secifabey&he#18p&e_n06=
%7
qdu
%2
)8!4"
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG
=
True
...
...
@@ -30,57 +31,58 @@ ALLOWED_HOSTS = ["*"]
# Application definition
INSTALLED_APPS
=
[
'django.contrib.admin'
,
'django.contrib.auth'
,
'django.contrib.contenttypes'
,
'django.contrib.sessions'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
'social'
,
'bootstrap4'
,
'django_ace'
,
'captcha'
"django.contrib.admin"
,
"django.contrib.auth"
,
"django.contrib.contenttypes"
,
"django.contrib.sessions"
,
"django.contrib.messages"
,
"django.contrib.staticfiles"
,
"social"
,
"bootstrap4"
,
"django_ace"
,
"captcha"
,
"django_cron"
,
]
MIDDLEWARE
=
[
'django.middleware.security.SecurityMiddleware'
,
'whitenoise.middleware.WhiteNoiseMiddleware'
,
'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'
,
"django.middleware.security.SecurityMiddleware"
,
"whitenoise.middleware.WhiteNoiseMiddleware"
,
"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"
,
]
ROOT_URLCONF
=
'aspava.urls'
ROOT_URLCONF
=
"aspava.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'
,
]
,
"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
=
'aspava.wsgi.application'
WSGI_APPLICATION
=
"aspava.wsgi.application"
# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
DATABASES
=
{
'default'
:
{
'ENGINE'
:
'django.db.backends.sqlite3'
,
'NAME'
:
os
.
path
.
join
(
BASE_DIR
,
'db.sqlite3'
),
"default"
:
{
"ENGINE"
:
"django.db.backends.sqlite3"
,
"NAME"
:
os
.
path
.
join
(
BASE_DIR
,
"db.sqlite3"
),
}
}
...
...
@@ -94,9 +96,9 @@ AUTH_PASSWORD_VALIDATORS = []
# Internationalization
# https://docs.djangoproject.com/en/2.0/topics/i18n/
LANGUAGE_CODE
=
'en-us'
LANGUAGE_CODE
=
"en-us"
TIME_ZONE
=
'UTC'
TIME_ZONE
=
"UTC"
USE_I18N
=
True
...
...
@@ -108,15 +110,18 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/
STATIC_URL
=
'/static/'
STATIC_URL
=
"/static/"
# Settings
LOGIN_REDIRECT_URL
=
'/'
LOGOUT_REDIRECT_URL
=
'/'
AUTH_USER_MODEL
=
'social.SocialUser'
LOGIN_REDIRECT_URL
=
"/"
LOGOUT_REDIRECT_URL
=
"/"
AUTH_USER_MODEL
=
"social.SocialUser"
# Extra Settings
MAX_POST_LENGTH
=
144
*
2
AVATAR_BASE
=
'img/avatars/avatar_{}.png'
AVATAR_BASE
=
"img/avatars/avatar_{}.png"
DESC
=
"Apparently, this user prefers to keep an air of mystery about them."
# Crons
CRON_CLASSES
=
[
"social.cronjobs.RenewEvalityCron"
]
aspava/urls.py
Dosyayı görüntüle @
c7eab392
...
...
@@ -19,6 +19,6 @@ from django.contrib import admin
from
django.urls
import
include
,
path
urlpatterns
=
[
path
(
''
,
include
(
'social.urls'
)),
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
""
,
include
(
"social.urls"
)),
path
(
"admin/"
,
admin
.
site
.
urls
),
]
+
static
(
settings
.
STATIC_URL
)
manage.py
Dosyayı görüntüle @
c7eab392
...
...
@@ -2,12 +2,9 @@
import
atexit
import
os
import
sys
from
social.utils
import
quit_evality
@atexit.register
def
quit
():
from
social.views
import
evality
evality
.
quit
()
atexit
.
register
(
quit_evality
)
if
__name__
==
"__main__"
:
os
.
environ
.
setdefault
(
"DJANGO_SETTINGS_MODULE"
,
"aspava.settings"
)
try
:
...
...
social/cronjobs/__init__.py
0 → 100644
Dosyayı görüntüle @
c7eab392
from
social.cronjobs.renew_evality
import
RenewEvalityCron
social/cronjobs/renew_evality.py
0 → 100644
Dosyayı görüntüle @
c7eab392
from
django_cron
import
CronJobBase
,
Schedule
from
social.utils
import
quit_evality
class
RenewEvalityCron
(
CronJobBase
):
RUN_EVERY_MINS
=
1
schedule
=
Schedule
(
run_every_mins
=
RUN_EVERY_MINS
)
code
=
'social.cronjobs.RenewEvalityCron'
def
do
(
self
):
quit_evality
()
social/utils/__init__.py
0 → 100644
Dosyayı görüntüle @
c7eab392
from
social.utils.quitter
import
quit_evality
social/utils/quitter.py
0 → 100644
Dosyayı görüntüle @
c7eab392
import
docker.errors
from
contextlib
import
suppress
def
quit_evality
():
from
social.views
import
evality
,
docker_client
evality
.
quit
()
for
container
in
docker_client
.
containers
.
list
():
if
"evality:latest"
in
container
.
image
.
tags
:
with
suppress
(
docker
.
errors
.
DockerException
):
container
.
kill
()
social/views/__init__.py
Dosyayı görüntüle @
c7eab392
import
docker
import
docker.errors
from
django.views.decorators.csrf
import
csrf_exempt
from
django.http
import
JsonResponse
from
django.shortcuts
import
get_object_or_404
...
...
@@ -29,7 +30,7 @@ def run_snippet(request):
global
evality
try
:
result
=
evality
.
run_cmd
(
snippet
.
text
,
snippet
.
author
.
id
)
except
docker
.
e
xception
s
.
DockerException
:
except
docker
.
e
rror
s
.
DockerException
:
evality
.
quit
()
result
[
'id'
]
=
snippet
.
id
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment