mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
This commit is contained in:
@@ -103,4 +103,4 @@ if not os.path.exists(PROJECT_LOGS_FOLDER):
|
||||
|
||||
if __name__ == '__main__':
|
||||
# run app instance
|
||||
app.run(host=FLASK_HOST, port=FLASK_PORT, threaded=True)
|
||||
app.run(host=FLASK_HOST, port=FLASK_PORT)
|
||||
|
||||
@@ -14,3 +14,4 @@ eventlet
|
||||
Celery
|
||||
Flower
|
||||
redis
|
||||
gunicorn
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import atexit
|
||||
import fcntl
|
||||
|
||||
import requests
|
||||
from apscheduler.schedulers.background import BackgroundScheduler
|
||||
from apscheduler.jobstores.mongodb import MongoDBJobStore
|
||||
@@ -65,8 +68,19 @@ class Scheduler(object):
|
||||
print(f'running: {self.scheduler.running}')
|
||||
|
||||
def run(self):
|
||||
self.update()
|
||||
self.scheduler.start()
|
||||
f = open("scheduler.lock", "wb")
|
||||
try:
|
||||
fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
self.update()
|
||||
self.scheduler.start()
|
||||
except:
|
||||
pass
|
||||
|
||||
def unlock():
|
||||
fcntl.flock(f, fcntl.LOCK_UN)
|
||||
f.close()
|
||||
|
||||
atexit.register(unlock)
|
||||
|
||||
|
||||
scheduler = Scheduler()
|
||||
|
||||
Reference in New Issue
Block a user