1.起動用シェルファイルを作成
/home/ec2-user/jnlpd.sh
#!/bin/bash
cd /home/ec2-user
java -jar agent.jar -jnlpUrl http://172.31.34.77:8080/computer/jnlp/jenkins-agent.jnlp -secret xxxxyyyyzzz -workDir "/home/ec2-user" &
2.unitファイルを作成
/etc/systemd/system/jnlpd.service
[Unit]
Description=jnlp connection daemon
After=network.target
[Service]
SuccessExitStatus=143
Type=forking
User=ec2-user
Group=ec2-user
ExecStart=/home/ec2-user/jnlpd.sh
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
3.サービスをenable・start
sudo systemctl daemon-reload
sudo systemctl enable jnlpd
sudo systemctl start jnlpd