Я использую планировщик в качестве службы Linux.
Я создал файл /etc/systemd/system/web2py-sched.service
[Unit]
Description=Web2Py scheduler service
[Service]
ExecStart=/usr/bin/python /home/www-data/web2py/web2py.py -K myApp
Type=simple
Restart=always
[Install]
WantedBy=multi-user.target
Затем установите службу, вызвав:
sudo systemctl enable /etc/systemd/system/web2py-sched.service
systemctl start /etc/systemd/system/web2py-sched
Теперь, после одного дня работы, я вижу, что происходит сбой Postgress DB или происходит сбой сервера apache.Я не смог отследить логи apache.Но в Postgress Logs я обнаружил:
2018-10-10 06:56:17 PDT [22303-1] spm@mydb LOG: unexpected EOF on client connection with an open transaction
2018-10-10 06:56:17 PDT [18799-7] LOG: server process (PID 22304) was terminated by signal 9: Killed
2018-10-10 06:56:17 PDT [18799-8] DETAIL: Failed process was running: SELECT "scheduler_task"."id", "scheduler_task"."application_name", "scheduler_task"."task_name", "scheduler_task"."group_name", "scheduler_task"."status", "scheduler_task"."function_name", "scheduler_task"."uuid", "scheduler_task"."args", "scheduler_task"."vars", "scheduler_task"."enabled", "scheduler_task"."start_time", "scheduler_task"."next_run_time", "scheduler_task"."stop_time", "scheduler_task"."repeats", "scheduler_task"."retry_failed", "scheduler_task"."period", "scheduler_task"."prevent_drift", "scheduler_task"."cronline", "scheduler_task"."timeout", "scheduler_task"."sync_output", "scheduler_task"."times_run", "scheduler_task"."times_failed", "scheduler_task"."last_run_time", "scheduler_task"."assigned_worker_name" FROM "scheduler_task" WHERE (("scheduler_task"."assigned_worker_name" = 'myApp#22265') AND ("scheduler_task"."status" = 'ASSIGNED')) ORDER BY "scheduler_task"."next_run_time" LIMIT 1 OFFSET 0;
2018-10-10 06:56:17 PDT [18799-9] LOG: terminating any other active server processes
2018-10-10 06:56:17 PDT [22256-2] WARNING: terminating connection because of crash of another server process
2018-10-10 06:56:17 PDT [22256-3] DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2018-10-10 06:56:17 PDT [22256-4] HINT: In a moment you should be able to reconnect to the database and repeat your command.
2018-10-10 06:56:17 PDT [18799-10] LOG: all server processes terminated; reinitializing
2018-10-10 06:56:17 PDT [22457-1] LOG: database system was interrupted; last known up at 2018-10-10 06:55:04 PDT
2018-10-10 06:56:18 PDT [22457-2] LOG: database system was not properly shut down; automatic recovery in progress
2018-10-10 06:56:18 PDT [22457-3] LOG: redo starts at 0/C1C85F94
2018-10-10 06:56:18 PDT [22457-4] LOG: invalid record length at 0/C1C88100
2018-10-10 06:56:18 PDT [22457-5] LOG: redo done at 0/C1C880DC
2018-10-10 06:56:18 PDT [22457-6] LOG: last completed transaction was at log time 2018-10-10 06:56:16.925482-07
2018-10-10 06:56:18 PDT [22457-7] LOG: MultiXact member wraparound protections are now enabled
2018-10-10 06:56:18 PDT [18799-11] LOG: database system is ready to accept connections
2018-10-10 06:56:18 PDT [22491-1] LOG: autovacuum launcher started
2018-10-10 06:56:31 PDT [22500-1] spm@mydb LOG: unexpected EOF on client connection with an open transaction
2018-10-10 06:56:31 PDT [22501-1] spm@mydb LOG: unexpected EOF on client connection with an open transaction
2018-10-10 06:56:31 PDT [22594-1] spm@mydb LOG: unexpected EOF on client connection with an open transaction
2018-10-10 06:56:31 PDT [22595-1] spm@mydb LOG: unexpected EOF on client connection with an open transaction
2018-10-10 06:56:33 PDT [18799-12] LOG: autovacuum launcher process (PID 22491) was terminated by signal 9: Killed
2018-10-10 06:56:33 PDT [18799-13] LOG: terminating any other active server processes
2018-10-10 06:56:33 PDT [18799-14] LOG: all server processes terminated; reinitializing
2018-10-10 06:56:33 PDT [22638-1] LOG: database system was interrupted; last known up at 2018-10-10 06:56:18 PDT
2018-10-10 06:56:33 PDT [18799-15] LOG: startup process (PID 22638) was terminated by signal 9: Killed
2018-10-10 06:56:33 PDT [18799-16] LOG: aborting startup due to startup process failure
Я убедился, что все транзакции зафиксированы.Но похоже ли это, что код завершается в какой-то момент перед вызовом коммита.
В журналах выше:
2018-10-10 06:56:17 PDT [18799-8] DETAIL: Failed process was running: SELECT "scheduler_task"."id", "scheduler_task"."application_name", "scheduler_task"."task_name", "scheduler_task"."group_name", "scheduler_task"."status", "scheduler_task"."function_name", "scheduler_task"."uuid", "scheduler_task"."args", "scheduler_task"."vars", "scheduler_task"."enabled", "scheduler_task"."start_time", "scheduler_task"."next_run_time", "scheduler_task"."stop_time", "scheduler_task"."repeats", "scheduler_task"."retry_failed", "scheduler_task"."period", "scheduler_task"."prevent_drift", "scheduler_task"."cronline", "scheduler_task"."timeout", "scheduler_task"."sync_output", "scheduler_task"."times_run", "scheduler_task"."times_failed", "scheduler_task"."last_run_time", "scheduler_task"."assigned_worker_name" FROM "scheduler_task" WHERE (("scheduler_task"."assigned_worker_name" = 'myApp#22265') AND ("scheduler_task"."status" = 'ASSIGNED')) ORDER BY "scheduler_task"."next_run_time" LIMIT 1 OFFSET 0;
Версия
2.15.4-stable+timestamp.2017.09.02.04.02.22
(Running on Apache/2.4.18 (Ubuntu), Python 2.7.12)