前提・実現したいこと
centos7でspringbootのアプリケーションをサービスとして動かしたいです。
発生している問題・エラーメッセージ
[root@scan-test2 app]# systemctl start test [root@scan-test2 app]# systemctl status test ● test.service Loaded: loaded (/etc/systemd/system/test.service; static; vendor preset: disabled) Active: failed (Result: exit-code) since Wed 2019-11-13 09:46:13 UTC; 1s ago Process: 10394 ExecStart=/opt/app/test.sh (code=exited, status=1/FAILURE) Main PID: 10394 (code=exited, status=1/FAILURE) Nov 13 09:46:13 scan-test2 test.sh[10394]: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Nat...a:62) Nov 13 09:46:13 scan-test2 test.sh[10394]: at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke...a:43) Nov 13 09:46:13 scan-test2 test.sh[10394]: at java.base/java.lang.reflect.Method.invoke(Method.java:566) Nov 13 09:46:13 scan-test2 test.sh[10394]: at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRun...a:48) Nov 13 09:46:13 scan-test2 test.sh[10394]: at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) Nov 13 09:46:13 scan-test2 test.sh[10394]: at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) Nov 13 09:46:13 scan-test2 test.sh[10394]: at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) Nov 13 09:46:13 scan-test2 systemd[1]: test.service: main process exited, code=exited, status=1/FAILURE Nov 13 09:46:13 scan-test2 systemd[1]: Unit test.service entered failed state. Nov 13 09:46:13 scan-test2 systemd[1]: test.service failed. Hint: Some lines were ellipsized, use -l to show in full.
試したこと
ScanTest.jarというjarファイルを作成しました。
これはサーバー上で
java -jar /opt/app/ScanTest.jar
のように実行すると期待通りの動きをします。
ただ、今回はサービスとして動かしたかったのでCentOS7でのSpring Bootの起動についてとSpring bootドキュメントを参考に以下のtest.serviceファイルを /etc/systemd/system に置きました。
[Unit] Description = springboottest [Service] ExecStart = /opt/app/ScanTest.jar Type = simple User = tomcat SuccessExitStatus = 143 [Install]
ファイルを作成後
systemctl start test systemctl status test
でステータスを確認しましたが、上記のエラーメッセージになりました。
この手法を試す前に色々としてしまったのでどこかでおかしくなってしまったのかもしれませんが、何かわかる方ややり方が違うという方がいたら教えてください。
補足情報(FW/ツールのバージョンなど)
centos7 AWS
あなたの回答
tips
プレビュー