使用Python脚本的服务失败,结果为“超时”(Redhat 8.2)

2024-09-28 20:56:53 发布

您现在位置:Python中文网/ 问答频道 /正文

这是我自己创建的/etc/systemd/system中的服务主体:

[Unit]
Description=EasyStart_rivals
#start EasyStart_rivals.py

[Service]
Type=forking
ExecStart=python3 /home/semenovvd/scripts/EasyStart_rivals.py
ExecStop=/home/semenovvd/pkill EasyStart_rivals.py
TimeOutSec=Infinity

[Install]
WantedBy=multi-user.target

我尝试过TimeOutSec=Infinity或TimeOutSec=0。我从service EasyStart_rivals.service start开始。脚本正在工作,响应请求。但无论如何,在2米30秒后,脚本因超时而失败。journalctl-xe中的日志:

Apr 11 09:40:44 UIDST-ES-WEB01D.passport.local systemd[1]: EasyStart_rivals.service: start operation timed out. Terminating.
Apr 11 09:40:44 UIDST-ES-WEB01D.passport.local systemd[1]: EasyStart_rivals.service: Failed with result 'timeout'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- The unit EasyStart_rivals.service has entered the 'failed' state with result 'timeout'.
Apr 11 09:40:44 UIDST-ES-WEB01D.passport.local systemd[1]: Failed to start EasyStart_rivals.

我的python脚本的文本是:

import pandas as pd
import geopandas as gpd
from flask import Flask, request
from flask_cors import CORS
from shapely.geometry import Point
from shapely.ops import cascaded_union
import json
import numpy as np
import requests

app = Flask(__name__)
cors = CORS(app)

@app.route("/api/v2/")
def api_v2():
    return json.dumps("jsontest")    

if __name__ == '__main__':
   app.run(host='0.0.0.0', port=5004)

我做错了什么


Tags: frompyimport脚本appesservicestart