当我启动服务并立即检查状态时,sudo systemctl status myservice
它似乎处于活动状态并开始运行,但几秒钟后它移动到Failed to start service
并显示
Failed with result exit code
Service hold-off time over sheduling restart
Stopped service
Start request repeated too quickly
Failed to start service
文件:
[Unit]
Description=myservice
[Service]
ExecStart=/bin/sh /opt/df/run.sh -pidfile=/var/run/myservice.pid
Restart=always
RestartSec=60
SyslogIdentifier=myservice
[Install]
WantedBy=multi-user.target
要记住的一件事是,为了让脚本开始运行(/opt/df 中的 run.sh),它需要大约一分钟或更长时间。
我不确定这是否与这个问题有关。
- - - - - - 更新 - - - - - - - -
嗯..我运行journalctl -xe
并发现:
Activating virtualenv at .venv
Ignoring indexes: https://pypi.python.org/simple
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 328, in runwb.build(autobuilding=True)
File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 748, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 360, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 448, in _prepare_file
req_to_install, finder)
File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 387, in _check_skip_installed
req_to_install.check_if_exists()
File "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 1011, in check_if_exists
self.req.project_name
AttributeError: 'Requirement' object has no attribute 'project_name'
myservice.service: Main process exited, code=exited, status=1/FAILURE
如果我只是运行脚本(没有服务的 run.sh):
Activating virtualenv at .venv
Ignoring indexes: https://pypi.python.org/simple
Requirement already up-to-date: pip==8.0.2+gx2 in ~/.local/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): bx-python==0.7.3 in ~/anaconda2/lib/python2.7/site-packages (from -r requirements.txt (line 2))
Requirement already satisfied (use --upgrade to upgrade): MarkupSafe==0.23 in ~/anaconda2/lib/python2.7/site-packages (from -r requirements.txt (line 3))
Requirement already satisfied (use --upgrade to upgrade): PyYAML==3.11 in ~/anaconda2/lib/python2.7/site-packages (from -r requirements.txt (line 4))
Requirement already satisfied (use --upgrade to upgrade): SQLAlchemy==1.0.8 in ~/anaconda2/lib/python2.7/site-packages (from -r requirements.txt (line 5))
....
那么,服务似乎找不到正确的 python 路径? (我正在使用的 anaconda 路径)?