1.起動用シェルファイルを作成
/home/ec2-user/swarmd.sh
#!/bin/bash
cd /home/ec2-user
java -jar /home/ec2-user/swarm-client-3.29.jar -executors 2 -disableSslVerification -master http://172.31.34.77:8080 -name swarm-node -username admin -password xxxxxx -mode exclusive &
2.unitファイルを作成
/etc/systemd/system/swarmd.service
[Unit]
Description=swarm connection daemon
After=network.target
[Service]
SuccessExitStatus=143
Type=forking
User=ec2-user
Group=ec2-user
ExecStart=/home/ec2-user/swarmd.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 swarmd
sudo systemctl start swarmd