# Systemd unit file for tomcat_<%= @instance %>

[Unit]
Description=<%= @instance %> Apache Tomcat Application
After=syslog.target network.target

[Service]
Type=forking

<% @env_vars.each do |h| -%>
  <% h.each_pair do |k,v| -%>
Environment="<%= k -%>=<%= v %>"
  <% end -%>
<% end -%>

ExecStart=<%= @install_path %>/bin/catalina.sh start
ExecStop=<%= @install_path %>/bin/catalina.sh stop

User=tomcat_<%= @instance %>
Group=tomcat_<%= @instance %>

[Install]
WantedBy=multi-user.target

# Systemd unit file for tomcat_<%= @instance %>

[Unit]
Description=<%= @instance %> Apache Tomcat Application
After=syslog.target network.target

[Service]
Type=simple

<% @env_vars.each do |h| -%>
  <% h.each_pair do |k,v| -%>
Environment="<%= k -%>=<%= v %>"
  <% end -%>
<% end -%>

ExecStart=<%= @install_path %>/bin/catalina.sh run
ExecStop=<%= @install_path %>/bin/catalina.sh stop

User=tomcat_<%= @instance %>
Group=tomcat_<%= @instance %>

[Install]
WantedBy=multi-user.target

Fix Tomcat 7 installs with systemd
Fix Tomcat 7 installs with systemd

The catalina.sh script seems to fail when we fork in the script. If we run in the foreground with catalina.sh and let systemd handle it things seem to work.
