Amazon Linux 2에서 systemd 서비스가 실패하는 이유는 무엇입니까?

Amazon Linux 2에서 systemd 서비스가 실패하는 이유는 무엇입니까?

Amazon Linux 2를 실행하는 AWS EC2 인스턴스에서 Node.js 애플리케이션을 복제했습니다.

server.js프로젝트 파일을 정상적으로 실행할 수 있습니다.

[ec2-user@ip-*********** portfolio_v3]$ nvm use 16
Now using node v16.19.1

[ec2-user@ip-*********** portfolio_v3]$ MAIL_JET_API_KEY_PRIVATE="..." NYT_API_KEY="..." node server.js
...

응용 프로그램이 항상 실행되고 다음을 따르도록 시스템 서비스를 만들려고 합니다.이 연습

나는 다음을 가지고 있습니다/etc/systemd/system/portfolio-v3.service

[Unit]
Description=portfolio-v3
After=multi-user.target

[Service]
Environment=MJ_API_KEY_PRIVATE=1234567890
Environment=NYT_API_KEY=1234567890
ExecStart=/home/.nvm/versions/node/v16.19.1/bin/node /home/ec2-user/portfolio-v3/server.js
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=portfolio-v3
User=ec2-user

[Install]
WantedBy=multi-user.target

다음 명령을 모두 다른 순서로 실행했습니다.

sudo chmod 644 /etc/systemd/system/portfolio-v3.service
sudo systemctl daemon-reload
sudo systemctl enable portfolio-v3.service
sudo systemctl start portfolio-v3.service

하지만 계속해서 다음과 같은 내용이 표시됩니다.

$ sudo systemctl status portfolio-v3.service
● portfolio-v3.service - portfolio-v3
   Loaded: loaded (/etc/systemd/system/portfolio-v3.service; enabled; vendor preset: disabled)
   Active: activating (auto-restart) (Result: exit-code) since Thu 2023-03-16 04:55:42 UTC; 8s ago
  Process: 7067 ExecStart=/home/.nvm/versions/node/v16.19.1/bin/node /home/ec2-user/portfolio-v3/server.js (code=exited, status=203/EXEC)
 Main PID: 7067 (code=exited, status=203/EXEC)

Mar 16 04:55:42 ip-172-31-18-127.us-west-2.compute.internal systemd[1]: portfolio-v3.service: main process exited, code=exited, status=203/EXEC
Mar 16 04:55:42 ip-172-31-18-127.us-west-2.compute.internal systemd[1]: Unit portfolio-v3.service entered failed state.
Mar 16 04:55:42 ip-172-31-18-127.us-west-2.compute.internal systemd[1]: portfolio-v3.service failed.

$ systemctl
UNIT                                                          LOAD   ACTIVE     SUB          DESCRIPTION
proc-sys-fs-binfmt_misc.automount                             loaded active     waiting      Arbitrary Executable File Formats File System Automount Point
sys-devices-platform-serial8250-tty-ttyS1.device              loaded active     plugged      /sys/devices/platform/serial8250/tty/ttyS1
sys-devices-platform-serial8250-tty-ttyS2.device              loaded active     plugged      /sys/devices/platform/serial8250/tty/ttyS2
sys-devices-platform-serial8250-tty-ttyS3.device              loaded active     plugged      /sys/devices/platform/serial8250/tty/ttyS3
sys-devices-pnp0-00:06-tty-ttyS0.device                       loaded active     plugged      /sys/devices/pnp0/00:06/tty/ttyS0
sys-devices-vbd\x2d51712-block-xvda-xvda1.device              loaded active     plugged      /sys/devices/vbd-51712/block/xvda/xvda1
sys-devices-vbd\x2d51712-block-xvda.device                    loaded active     plugged      /sys/devices/vbd-51712/block/xvda
sys-devices-vif\x2d0-net-eth0.device                          loaded active     plugged      /sys/devices/vif-0/net/eth0
sys-subsystem-net-devices-eth0.device                         loaded active     plugged      /sys/subsystem/net/devices/eth0
-.mount                                                       loaded active     mounted      /
dev-hugepages.mount                                           loaded active     mounted      Huge Pages File System
dev-mqueue.mount                                              loaded active     mounted      POSIX Message Queue File System
run-user-1000.mount                                           loaded active     mounted      /run/user/1000
sys-kernel-debug.mount                                        loaded active     mounted      Debug File System
var-lib-nfs-rpc_pipefs.mount                                  loaded active     mounted      RPC Pipe File System
brandbot.path                                                 loaded active     waiting      Flexible branding
systemd-ask-password-plymouth.path                            loaded active     waiting      Forward Password Requests to Plymouth Directory Watch
systemd-ask-password-wall.path                                loaded active     waiting      Forward Password Requests to Wall Directory Watch
session-897.scope                                             loaded active     running      Session 897 of user ec2-user
acpid.service                                                 loaded active     running      ACPI Event Daemon
amazon-ssm-agent.service                                      loaded active     running      amazon-ssm-agent
atd.service                                                   loaded active     running      Job spooling tools
auditd.service                                                loaded active     running      Security Auditing Service
chronyd.service                                               loaded active     running      NTP client/server
cloud-config.service                                          loaded active     exited       Apply the settings specified in cloud-config
cloud-final.service                                           loaded active     exited       Execute cloud user/final scripts
cloud-init-local.service                                      loaded active     exited       Initial cloud-init job (pre-networking)
cloud-init.service                                            loaded active     exited       Initial cloud-init job (metadata service crawler)
crond.service                                                 loaded active     running      Command Scheduler
dbus.service                                                  loaded active     running      D-Bus System Message Bus
[email protected]                                            loaded active     running      Getty on tty1
gssproxy.service                                              loaded active     running      GSSAPI Proxy Daemon
kmod-static-nodes.service                                     loaded active     exited       Create list of required static device nodes for the current kernel
libstoragemgmt.service                                        loaded active     running      libstoragemgmt plug-in server daemon
lvm2-lvmetad.service                                          loaded active     running      LVM2 metadata daemon
lvm2-monitor.service                                          loaded active     exited       Monitoring of LVM2 mirrors, snapshots etc. using dmeventd or progress polling
network.service                                               loaded active     running      LSB: Bring up/down networking
portfolio-v3.service                                          loaded activating auto-restart portfolio-v3

어떤 아이디어가 있나요? 또한 구글링을 했지만 code=exited, status=203/EXEC결과는 여기저기에 있었습니다.

감사해요:)


편집하다

server.js원하는 노드 버전의 절대 경로를 사용하여 직접 실행 하려고 하면 실패합니다.

[ec2-user@ip-172-31-18-127 portfolio_v3]$ /home/.nvm/versions/node/v16.19.1/bin/node server.js
-bash: /home/.nvm/versions/node/v16.19.1/bin/node: No such file or directory
[ec2-user@ip-172-31-18-127 portfolio_v3]$ cd
[ec2-user@ip-172-31-18-127 ~]$ ls -a
.  ..  .bash_history  .bash_logout  .bash_profile  .bashrc  .gitconfig  .lesshst  .npm  .nvm  portfolio_v3  .ssh  .vim  .viminfo  .vimrc
[ec2-user@ip-172-31-18-127 ~]$ cd .nvm
[ec2-user@ip-172-31-18-127 .nvm]$ ls
alias  bash_completion  nvm-exec  nvm.sh  versions
[ec2-user@ip-172-31-18-127 .nvm]$ cd versions
[ec2-user@ip-172-31-18-127 versions]$ ls
node
[ec2-user@ip-172-31-18-127 versions]$ cd node
[ec2-user@ip-172-31-18-127 node]$ ls
v16.19.1  v18.15.0
[ec2-user@ip-172-31-18-127 node]$ cd v16.19.1/
[ec2-user@ip-172-31-18-127 v16.19.1]$ ls
bin  CHANGELOG.md  include  lib  LICENSE  README.md  share
[ec2-user@ip-172-31-18-127 v16.19.1]$ cd bin
[ec2-user@ip-172-31-18-127 bin]$ ls
corepack  node  npm  npx
[ec2-user@ip-172-31-18-127 bin]$ which node
~/.nvm/versions/node/v18.15.0/bin/node
[ec2-user@ip-172-31-18-127 bin]$

관련 정보