2022-10-25 20:55:11 +00:00
|
|
|
"""Start the appscheduler in blocking mode."""
|
|
|
|
import time
|
|
|
|
|
|
|
|
from apscheduler.schedulers.background import BlockingScheduler # type: ignore
|
|
|
|
from spiffworkflow_backend import create_app
|
2023-12-05 16:41:59 +00:00
|
|
|
from spiffworkflow_backend.background_processing.apscheduler import start_apscheduler
|
2023-08-10 12:54:49 +00:00
|
|
|
from spiffworkflow_backend.data_migrations.version_1_3 import VersionOneThree
|
2022-10-25 20:55:11 +00:00
|
|
|
from spiffworkflow_backend.helpers.db_helper import try_to_connect
|
|
|
|
|
|
|
|
|
|
|
|
def main() -> None:
|
2023-08-10 12:54:49 +00:00
|
|
|
seconds_to_wait = 300
|
|
|
|
print(f"sleeping for {seconds_to_wait} seconds to give the api container time to run the migration")
|
|
|
|
time.sleep(seconds_to_wait)
|
|
|
|
print("done sleeping")
|
|
|
|
|
|
|
|
print("running data migration from background processor")
|
2022-10-25 20:55:11 +00:00
|
|
|
app = create_app()
|
|
|
|
start_time = time.time()
|
2023-08-10 12:54:49 +00:00
|
|
|
|
2022-10-25 20:55:11 +00:00
|
|
|
with app.app_context():
|
|
|
|
try_to_connect(start_time)
|
2023-08-10 12:54:49 +00:00
|
|
|
VersionOneThree().run()
|
2022-10-25 20:55:11 +00:00
|
|
|
|
2023-08-10 12:54:49 +00:00
|
|
|
end_time = time.time()
|
2023-12-05 16:41:59 +00:00
|
|
|
print(f"done running data migration from background processor. took {end_time - start_time} seconds. starting scheduler")
|
|
|
|
start_apscheduler(app, BlockingScheduler)
|
2022-10-25 20:55:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|