[Bugfix] terminal tasks main()运行时,可能数据库还不存在

pull/828/merge
ibuler 7 years ago
parent ec8106e43d
commit 15f6d5c9c0

@ -5,10 +5,12 @@ import time
from celery import shared_task from celery import shared_task
from django.core.cache import cache from django.core.cache import cache
from django.db.utils import ProgrammingError
from .models import Session from .models import Session
ASSETS_CACHE_KEY = "terminal__session__assets" ASSETS_CACHE_KEY = "terminal__session__assets"
USERS_CACHE_KEY = "terminal__session__users" USERS_CACHE_KEY = "terminal__session__users"
SYSTEM_USER_CACHE_KEY = "terminal__session__system_users" SYSTEM_USER_CACHE_KEY = "terminal__session__system_users"
@ -36,14 +38,18 @@ def get_session_system_user_list():
def set_cache(): def set_cache():
while True: while True:
assets = get_session_asset_list() try:
users = get_session_user_list() assets = get_session_asset_list()
system_users = get_session_system_user_list() users = get_session_user_list()
system_users = get_session_system_user_list()
cache.set(ASSETS_CACHE_KEY, assets) cache.set(ASSETS_CACHE_KEY, assets)
cache.set(USERS_CACHE_KEY, users) cache.set(USERS_CACHE_KEY, users)
cache.set(SYSTEM_USER_CACHE_KEY, system_users) cache.set(SYSTEM_USER_CACHE_KEY, system_users)
time.sleep(10) except ProgrammingError:
pass
finally:
time.sleep(10)
def main(): def main():
@ -59,4 +65,5 @@ def main():
t.start() t.start()
RUNNING = True RUNNING = True
# Todo: 不能migrations了
main() main()

@ -1,6 +1,11 @@
#!/bin/bash #!/bin/bash
# #
for app in users assets perms audits ops applications;do cd ../apps
rm -f ../apps/$app/migrations/00*
for d in $(ls);do
if [ -d $d ] && [ -d $d/migrations ];then
rm -f $d/migrations/00*
fi
done done

Loading…
Cancel
Save