|
|
@ -81,7 +81,7 @@ def check_database_connection(): |
|
|
|
logging.info("Database connect success") |
|
|
|
logging.info("Database connect success") |
|
|
|
return |
|
|
|
return |
|
|
|
time.sleep(1) |
|
|
|
time.sleep(1) |
|
|
|
logging.info("Connection database failed, exist") |
|
|
|
logging.error("Connection database failed, exist") |
|
|
|
sys.exit(10) |
|
|
|
sys.exit(10) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -93,7 +93,8 @@ def check_migrations(): |
|
|
|
return |
|
|
|
return |
|
|
|
for i in range(3): |
|
|
|
for i in range(3): |
|
|
|
print("!!! Warning: Has SQL migrations not perform, 有 SQL 变更没有执行") |
|
|
|
print("!!! Warning: Has SQL migrations not perform, 有 SQL 变更没有执行") |
|
|
|
print("You should run ./PROC upgrade first, 请先运行 ./PROC upgrade, 进行表结构变更") |
|
|
|
print("You should run `./PROC upgrade_db` first, 请先运行 ./PROC upgrade_db, 进行表结构变更") |
|
|
|
|
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def perform_db_migrate(): |
|
|
|
def perform_db_migrate(): |
|
|
@ -522,7 +523,7 @@ def show_service_status(s): |
|
|
|
print("{} is stopped".format(ns)) |
|
|
|
print("{} is stopped".format(ns)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def upgrade(): |
|
|
|
def upgrade_db(): |
|
|
|
collect_static() |
|
|
|
collect_static() |
|
|
|
perform_db_migrate() |
|
|
|
perform_db_migrate() |
|
|
|
|
|
|
|
|
|
|
@ -539,7 +540,7 @@ if __name__ == '__main__': |
|
|
|
) |
|
|
|
) |
|
|
|
parser.add_argument( |
|
|
|
parser.add_argument( |
|
|
|
'action', type=str, |
|
|
|
'action', type=str, |
|
|
|
choices=("start", "stop", "restart", "status", "upgrade"), |
|
|
|
choices=("start", "stop", "restart", "status", "upgrade_db"), |
|
|
|
help="Action to run" |
|
|
|
help="Action to run" |
|
|
|
) |
|
|
|
) |
|
|
|
parser.add_argument( |
|
|
|
parser.add_argument( |
|
|
@ -574,7 +575,7 @@ if __name__ == '__main__': |
|
|
|
stop_service(srv) |
|
|
|
stop_service(srv) |
|
|
|
time.sleep(5) |
|
|
|
time.sleep(5) |
|
|
|
start_services_and_watch(srv) |
|
|
|
start_services_and_watch(srv) |
|
|
|
elif action == "upgrade": |
|
|
|
elif action == "upgrade_db": |
|
|
|
upgrade() |
|
|
|
upgrade_db() |
|
|
|
else: |
|
|
|
else: |
|
|
|
show_service_status(srv) |
|
|
|
show_service_status(srv) |
|
|
|