[Add] Add initial migrations

This commit is contained in:
ibuler
2017-12-24 23:21:05 +08:00
parent bf9bb1b973
commit d0ef1e715e
7 changed files with 554 additions and 2 deletions

View File

@@ -23,7 +23,7 @@ WORKERS = 4
def start_gunicorn():
print("- Start Gunicorn WSGI HTTP Server")
print("# Start Gunicorn WSGI HTTP Server")
os.chdir(APPS_DIR)
cmd = "gunicorn jumpserver.wsgi -b {}:{} -w {}".format(HTTP_HOST, HTTP_PORT, WORKERS)
if DEBUG:
@@ -49,12 +49,35 @@ def start_beat():
subprocess.call(cmd, shell=True)
def make_migrations():
print("Check database change, make migrations")
os.chdir(os.path.join(BASE_DIR, 'utils'))
subprocess.call('bash make_migrations.sh', shell=True)
def load_init_data():
print("Load init data, if need")
os.chdir(APPS_DIR)
print(os.listdir(APPS_DIR))
os.environ['DJANGO_SETTINGS_MODULE'] = 'jumpserver.settings'
from users.models import User
was_initial = User.objects.all().count()
if not was_initial:
os.chdir(os.path.join(BASE_DIR, 'utils'))
subprocess.call('bash init_db.sh', shell=True)
else:
print("Has been initial, pass")
def main():
make_migrations()
load_init_data()
print(time.ctime())
print('Jumpserver version {}, more see https://www.jumpserver.org'.format(
__version__))
print('Quit the server with CONTROL-C.')
threads = []
for func in (start_gunicorn, start_celery, start_beat):
t = Thread(target=func, args=())