简体   繁体   中英

systemd failing to start custom made service for Tomcat

I am having getting a simple systemd service I have created to start up correctly.

Here is tomcat.service, which I have placed into /lib/systemd/system :

[Unit]
Description=A systemd daemon configured to run Apache Tomcat 8.
After=syslog.target network.target

[Service]
Type=forking
PIDFile=/home/technomage/Migration/Programming\ Files/Development\ Plugins\ and\ Software/apache-tomcat-8.0.26/bin/tomcat.pid
ExecStart=/home/technomage/Migration/Programming\ Files/Development\ Plugins\ and\ Software/apache-tomcat-8.0.26/bin/startup.sh
ExecStop=/home/technomage/Migration/Programming\ Files/Development\ Plugins\ and\ Software/apache-tomcat-8.0.26/bin/shutdown.sh

[Install]
WantedBy=multi-user.target

After placing the file into the folder, I have run systemctl enable tomcat.service .

After this, running sudo systemctl start tomcat.service gives me the following error:

Job for tomcat.service failed. See 'systemctl status tomcat.service' and 'journalctl -xn' for details.

Examining closely the error in question via sudo journalctl reveals the following related error:

Oct 24 19:22:05 theforge systemd[6674]: Failed at step EXEC spawning /home/technomage/Migration/Programming\ Files/Development\ Plugins\ and\ Software/apache-tomcat-8.0.26/bin/startup.sh: No such file or directory
Oct 24 19:22:05 theforge systemd[1]: tomcat.service: control process exited, code=exited status=203

However, I know for a fact that the location given to ExecStart exists, as I can paste this very tidbit into my shell and it will start up Tomcat perfectly!

So I am somewhat bewildered. I have attempted to remove the \\ s from the path, thinking that perhaps it utilizes some strange Windows-influenced style. Still nothing works.

Where have I messed up?

It turns out that the only way to utilize paths with spaces in unit files is to remove the escape characters and double quote the entire path.

[Service]
Type=forking
PIDFile="/home/technomage/Migration/Programming Files/Development Plugins and Software/apache-tomcat-8.0.26/bin/tomcat.pid"
ExecStart="/home/technomage/Migration/Programming Files/Development Plugins and Software/apache-tomcat-8.0.26/bin/startup.sh"
ExecStop="/home/technomage/Migration/Programming Files/Development Plugins and Software/apache-tomcat-8.0.26/bin/shutdown.sh"

This seems like an obvious solution, except that the problem here is this "feature" is only supported in a more recent version of systemd .

The systemd that comes with Debian Jessie (the distro I'm using) turns out to not have that feature. So the only way is to upgrade to the most recent version.

Debian Jessie comes out of the box with a very old version, 215-17 .

I solved this by temporarily changing my repositories to sid , updating my sources, and upgrading systemd .

With this, systemd now no longer has a problem with the pathway or finding the stated binaries.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM