systemctl .service 파일이 예상대로 작동하지 않습니다.

systemctl .service 파일이 예상대로 작동하지 않습니다.

Centos 7에서 서비스 파일을 사용하고 xymon용 서비스 파일을 만들고 있습니다. 내가 겪고 있는 문제는 시작, 중지 및 다시 시작을 구성하려고 한다는 것입니다. 가능하면 기존 서비스 파일을 템플릿으로 사용하지만, 어떤 옵션을 선택하든 "중지" 옵션이 사용됩니다.

# more xymon.service
[Unit]
Description=Xymon Monitor Service
After=network.target
[Service]
Type=simple
#User=xymon
ExecStart=/home/xymon/startup/xymon-init.d start
ExecReload=/home/xymon/startup/xymon-init.d restart
ExecStop=/home/xymon/startup/xymon-init.d stop
[Install]
WantedBy=multi-user.target

나는 간단한 것, 분기된 것, 그리고 몇 가지 다른 변형을 시도했지만 소용이 없었습니다. 첫 번째 매개변수가 인쇄되는 더미 스크립트를 넣었는데 항상 로그 파일에서 중지됩니다. 과거에 다른 유형의 서비스 파일을 문제 없이 수행해 본 적이 있지만, 이 systemctl을 시도하는 것은 이번이 처음입니다. 어떤 도움이라도 대단히 감사하겠습니다.

답변1

참고 - Argonauts의 답변은 일부 모드에서 작동합니다. 내 환경의 표준 설치를 기반으로 한 작업 버전은 다음과 같습니다.

# xymonlaunch.service
# systemd file for Fedora 18 and up, or RHEL 7 and up

[Unit]
Description=Xymon systems and network monitor
Documentation=man:xymon(7) man:xymonlaunch(8) man:xymon(1)
After=network.target

[Install]
# Compatibility with "xymon" and "xymon-client"
Alias=xymon.service
Alias=xymon-client.service
WantedBy=multi-user.target


[Service]
#EnvironmentFile=/etc/sysconfig/xymonlaunch
User=xymon
# We wrap in xymoncmd to eliminate the need for the bulk of the old init script
ExecStart=/home/xymon/server/bin/xymoncmd /home/xymon/server/bin/xymonlaunch --no-daemon $XYMONLAUNCHOPTS
Type=simple

# Kill xymonlaunch, but don't send kills to the underlying procs, since they
# might be doing important things (like writing checkpoints and flushing caches)
KillMode=process
# SendSIGHUP=yes
SendSIGKILL=no

답변2

일반적으로 systemd는 .service 단위 파일을 생성하지 않고 init.d 스크립트를 서비스로 변환할 수 있습니다. 스크립트가 init.d 디렉터리에 있고 실행 가능하며 systemd에서 성공적으로 구문 분석할 수 있는 경우 systemctl status xymon을 실행합니다( . 서비스 파일)이 작동할 수 있어야 합니다. 분명히 항상 그런 것은 아닙니다. 내 centos 7 시스템에 있는 유일한 서비스는 VMWare Workstation입니다. 이 경우 서비스 파일 없이 작동합니다.

다음은 init.d 스크립트를 사용하지 않고 systemd를 사용하여 xymon을 시작하는 데 권장되는 서비스 파일입니다. 문제가 제대로 작동하면 (그리고 확실히 재부팅하기 전에) init.d 영역 밖으로 옮겨야 할 수도 있습니다. 아마도 현재의 형태로는 작동하지 않을 것입니다. 그러나 여전히 파괴력을 발휘할 수는 있습니다.

이 사이트는 el7에 대한 rpms(및 srpms)를 제공합니다.http://terabithia.org/rpms/xymon/ 분명히 베타 버전이지만 공식 sourceforge 다운로드에는 없는 systemd 구성이 포함되어 있습니다.

# xymonlaunch.service
# systemd file for Fedora 18 and up, or RHEL 7 and up

[Unit]
Description=Xymon systems and network monitor
Documentation=man:xymon(7) man:xymonlaunch(8) man:xymon(1)
After=network.target

[Install]
# Compatibility with "xymon" and "xymon-client"
Alias=xymon.service
Alias=xymon-client.service
WantedBy=multi-user.target


[Service]
EnvironmentFile=/etc/sysconfig/xymonlaunch
User=xymon
# We wrap in xymoncmd to eliminate the need for the bulk of the old init script
ExecStart=/usr/bin/xymoncmd /usr/sbin/xymonlaunch --no-daemon $XYMONLAUNCHOPTS
Type=simple

# Kill xymonlaunch, but don't send kills to the underlying procs, since they
# might be doing important things (like writing checkpoints and flushing caches)
KillMode=process
# SendSIGHUP=yes
SendSIGKILL=no

관련 정보