Tmux에서 CLI 애플리케이션을 시작하는 systemd 서비스를 생성하고 활성화했지만(SELinux는 비활성화되어야 함) 재부팅 후 서비스를 수동으로 시작해야 합니다. 자동으로 시작되지 않는 이유를 어떻게 알 수 있나요?
서비스에 대한 몇 가지 정보는 다음과 같습니다.
[itadmin@SRV-LNX-RHEL01 ~]$ systemctl cat aescripts-LicenseServer.service
# /etc/systemd/system/aescripts-LicenseServer.service
[Unit]
Description="Service that keeps runing the aescripts license server from startup."
[Install]
WantedBy=rescue.target
[Service]
User=itadmin
Type=forking
ExecStart=/usr/bin/tmux new-session -s itadmin -d bash -c '/home/itadmin/Dev/aescriptsLicenseServer_v3.5.6/Linux/aescriptsLicenseServer'
WorkingDirectory=/home/itadmin/Dev/aescriptsLicenseServer_v3.5.6/Linux
Restart=always
RestartSec=5
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=%n
[itadmin@SRV-LNX-RHEL01 ~]$ systemctl status aescripts-LicenseServer.service
● aescripts-LicenseServer.service - "Service that keeps runing the aescripts license server from s>
Loaded: loaded (/etc/systemd/system/aescripts-LicenseServer.service; enabled; vendor preset: di>
Active: active (running) since Tue 2021-10-05 17:21:04 PDT; 5min ago
Process: 7723 ExecStart=/usr/bin/tmux new-session -s itadmin -d bash -c /home/itadmin/Dev/aescri>
Main PID: 7725 (tmux: server)
Tasks: 2 (limit: 8144)
Memory: 2.3M
CGroup: /system.slice/aescripts-LicenseServer.service
├─7725 /usr/bin/tmux new-session -s itadmin -d bash -c /home/itadmin/Dev/aescriptsLicen>
└─7726 /home/itadmin/Dev/aescriptsLicenseServer_v3.5.6/Linux/aescriptsLicenseServer
Oct 05 17:21:04 SRV-LNX-RHEL01 systemd[1]: Starting "Service that keeps runing the aescripts licen>
Oct 05 17:21:04 SRV-LNX-RHEL01 systemd[1]: Started "Service that keeps runing the aescripts licens>
[itadmin@SRV-LNX-RHEL01 ~]$ systemctl list-dependencies aescripts-LicenseServer.service
aescripts-LicenseServer.service
● ├─-.mount
● ├─home.mount
● ├─system.slice
● └─sysinit.target
● ├─dev-hugepages.mount
● ├─dev-mqueue.mount
● ├─dracut-shutdown.service
● ├─import-state.service
● ├─iscsi-onboot.service
● ├─kmod-static-nodes.service
● ├─ldconfig.service
● ├─loadmodules.service
● ├─lvm2-lvmpolld.socket
● ├─lvm2-monitor.service
● ├─multipathd.service
● ├─nis-domainname.service
● ├─plymouth-read-write.service
● ├─plymouth-start.service
● ├─proc-sys-fs-binfmt_misc.automount
● ├─selinux-autorelabel-mark.service
● ├─sys-fs-fuse-connections.mount
● ├─sys-kernel-config.mount
● ├─sys-kernel-debug.mount
● ├─systemd-ask-password-console.path
● ├─systemd-binfmt.service
● ├─systemd-firstboot.service
● ├─systemd-hwdb-update.service
● ├─systemd-journal-catalog-update.service
● ├─systemd-journal-flush.service
● ├─systemd-journald.service
● ├─systemd-machine-id-commit.service
● ├─systemd-modules-load.service
● ├─systemd-random-seed.service
● ├─systemd-sysctl.service
● ├─systemd-sysusers.service
● ├─systemd-tmpfiles-setup-dev.service
● ├─systemd-tmpfiles-setup.service
● ├─systemd-udev-trigger.service
● ├─systemd-udevd.service
● ├─systemd-update-done.service
● ├─systemd-update-utmp.service
● ├─cryptsetup.target
● ├─local-fs.target
● │ ├─-.mount
● │ ├─boot-efi.mount
● │ ├─boot.mount
● │ ├─home.mount
● │ └─systemd-remount-fs.service
● └─swap.target
● └─dev-mapper-rhel\x2dswap.swap
답변1
서비스는 복구 모드로 부팅할 때만 시작됩니다.
[Install]
WantedBy=rescue.target
rescue.target
A special target unit that pulls in the base system (including system mounts) and spawns a rescue shell. Isolate to this target in order to administer the system in single-user mode with all file systems mounted but with no services running, except for the most basic.
(에서https://www.freedesktop.org/software/systemd/man/systemd.special.html#rescue.target).
multi-user.target이 활성화되면 서비스를 시작하고 싶습니다.
multi-user.target
A special target unit for setting up a multi-user system (non-graphical). This is pulled in by graphical.target.
Units that are needed for a multi-user system shall add Wants= dependencies for their unit to this unit during installation. This is best configured via WantedBy=multi-user.target in the unit's [Install] section.
(https://www.freedesktop.org/software/systemd/man/systemd.special.html#multi-user.target)