mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-8625: Systemd profile for CloudStack Agent
With CentOS 7 and Ubuntu 16.04 (to be released) using systemd it is preferred that CloudStack's Agent is also being started using systemd. This commit includes a service file for the CloudStack Agent with a wrapper script which actually executes Java It no longer uses jsvc for daemonizing and thus this requirement has also been dropped for CentOS 7 packaging. The Agent log output to stdout has also been modified to no longer include the timestamp as this is done by journalctl. This has been tested on a CentOS 7.1 machine and the Agent starts, stops and restarts properly.
This commit is contained in:
parent
ff1ce07aef
commit
612c7ebf40
@ -47,7 +47,7 @@ under the License.
|
|||||||
<param name="Threshold" value="INFO"/>
|
<param name="Threshold" value="INFO"/>
|
||||||
|
|
||||||
<layout class="org.apache.log4j.PatternLayout">
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
<param name="ConversionPattern" value="%d{ISO8601}{GMT} %-5p [%c{3}] (%t:%x) %m%n"/>
|
<param name="ConversionPattern" value="%-5p [%c{3}] (%t:%x) %m%n"/>
|
||||||
</layout>
|
</layout>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
|
|||||||
@ -107,9 +107,6 @@ Requires: iptables
|
|||||||
Requires: ethtool
|
Requires: ethtool
|
||||||
Requires: iproute
|
Requires: iproute
|
||||||
Requires: ipset
|
Requires: ipset
|
||||||
Requires: jsvc
|
|
||||||
Requires: jakarta-commons-daemon
|
|
||||||
Requires: jakarta-commons-daemon-jsvc
|
|
||||||
Requires: perl
|
Requires: perl
|
||||||
Requires: libvirt-python
|
Requires: libvirt-python
|
||||||
Requires: qemu-img
|
Requires: qemu-img
|
||||||
@ -206,6 +203,7 @@ mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/scripts
|
|||||||
mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/vms
|
mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/vms
|
||||||
mkdir -p ${RPM_BUILD_ROOT}%{python_sitearch}/
|
mkdir -p ${RPM_BUILD_ROOT}%{python_sitearch}/
|
||||||
mkdir -p ${RPM_BUILD_ROOT}%/usr/bin
|
mkdir -p ${RPM_BUILD_ROOT}%/usr/bin
|
||||||
|
mkdir -p ${RPM_BUILD_ROOT}/usr/lib/systemd/system
|
||||||
cp -r scripts/* ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/scripts
|
cp -r scripts/* ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/scripts
|
||||||
install -D systemvm/dist/systemvm.iso ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/vms/systemvm.iso
|
install -D systemvm/dist/systemvm.iso ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/vms/systemvm.iso
|
||||||
install -D systemvm/dist/systemvm.zip ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/vms/systemvm.zip
|
install -D systemvm/dist/systemvm.zip ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/vms/systemvm.zip
|
||||||
@ -294,7 +292,7 @@ mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/agent
|
|||||||
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/agent
|
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/agent
|
||||||
mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib
|
mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib
|
||||||
mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/plugins
|
mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/plugins
|
||||||
install -D packaging/centos7/cloud-agent.rc ${RPM_BUILD_ROOT}%{_sysconfdir}/init.d/%{name}-agent
|
install -D packaging/systemd/cloudstack-agent.service ${RPM_BUILD_ROOT}/usr/lib/systemd/system/cloudstack-agent.service
|
||||||
install -D agent/target/transformed/agent.properties ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/agent/agent.properties
|
install -D agent/target/transformed/agent.properties ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/agent/agent.properties
|
||||||
install -D agent/target/transformed/environment.properties ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/agent/environment.properties
|
install -D agent/target/transformed/environment.properties ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/agent/environment.properties
|
||||||
install -D agent/target/transformed/log4j-cloud.xml ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/agent/log4j-cloud.xml
|
install -D agent/target/transformed/log4j-cloud.xml ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/agent/log4j-cloud.xml
|
||||||
@ -373,7 +371,6 @@ fi
|
|||||||
/sbin/service cloudstack-agent stop || true
|
/sbin/service cloudstack-agent stop || true
|
||||||
if [ "$1" == "0" ] ; then
|
if [ "$1" == "0" ] ; then
|
||||||
/sbin/chkconfig --del cloudstack-agent > /dev/null 2>&1 || true
|
/sbin/chkconfig --del cloudstack-agent > /dev/null 2>&1 || true
|
||||||
/sbin/service cloudstack-agent stop > /dev/null 2>&1 || true
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
%pre agent
|
%pre agent
|
||||||
@ -393,8 +390,7 @@ if [ "$1" == "1" ] ; then
|
|||||||
fi
|
fi
|
||||||
cp -a ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib/libvirtqemuhook %{_sysconfdir}/libvirt/hooks/qemu
|
cp -a ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib/libvirtqemuhook %{_sysconfdir}/libvirt/hooks/qemu
|
||||||
/sbin/service libvirtd restart
|
/sbin/service libvirtd restart
|
||||||
/sbin/chkconfig --add cloudstack-agent > /dev/null 2>&1 || true
|
/sbin/systemctl enable cloudstack-agent > /dev/null 2>&1 || true
|
||||||
/sbin/chkconfig --level 345 cloudstack-agent on > /dev/null 2>&1 || true
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if saved configs from upgrade exist, copy them over
|
# if saved configs from upgrade exist, copy them over
|
||||||
|
|||||||
32
packaging/systemd/cloudstack-agent-systemd-wrapper.sh
Executable file
32
packaging/systemd/cloudstack-agent-systemd-wrapper.sh
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
# or more contributor license agreements. See the NOTICE file
|
||||||
|
# distributed with this work for additional information
|
||||||
|
# regarding copyright ownership. The ASF licenses this file
|
||||||
|
# to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance
|
||||||
|
# with the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing,
|
||||||
|
# software distributed under the License is distributed on an
|
||||||
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
# KIND, either express or implied. See the License for the
|
||||||
|
# specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
#
|
||||||
|
# Wrapper for starting CloudStack Agent under systemd
|
||||||
|
#
|
||||||
|
# ExecStart=/usr/libexec/cloudstack/cloudstack-agent-systemd-wrapper.sh
|
||||||
|
#
|
||||||
|
|
||||||
|
ACP=`ls /usr/share/cloudstack-agent/lib/*.jar | tr '\n' ':' | sed s'/.$//'`
|
||||||
|
PCP=`ls /usr/share/cloudstack-agent/plugins/*.jar 2>/dev/null | tr '\n' ':' | sed s'/.$//'`
|
||||||
|
|
||||||
|
CLASSPATH="$ACP:$PCP:/etc/cloudstack/agent:/usr/share/cloudstack-common/scripts"
|
||||||
|
|
||||||
|
${JAVA_HOME}/bin/java -Xms${JAVA_HEAP_INITIAL} -Xmx${JAVA_HEAP_MAX} -cp "$CLASSPATH" $JAVA_CLASS
|
||||||
|
|
||||||
|
exit $?
|
||||||
35
packaging/systemd/cloudstack-agent.service
Normal file
35
packaging/systemd/cloudstack-agent.service
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
# or more contributor license agreements. See the NOTICE file
|
||||||
|
# distributed with this work for additional information
|
||||||
|
# regarding copyright ownership. The ASF licenses this file
|
||||||
|
# to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance
|
||||||
|
# with the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing,
|
||||||
|
# software distributed under the License is distributed on an
|
||||||
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
# KIND, either express or implied. See the License for the
|
||||||
|
# specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=CloudStack Agent
|
||||||
|
Documentation=http://www.cloudstack.org/
|
||||||
|
Requires=libvirtd.service
|
||||||
|
After=libvirtd.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
Environment=JAVA_HOME=/usr/lib/jvm/jre
|
||||||
|
Environment=JAVA_HEAP_INITIAL=256m
|
||||||
|
Environment=JAVA_HEAP_MAX=2048m
|
||||||
|
Environment=JAVA_CLASS=com.cloud.agent.AgentShell
|
||||||
|
ExecStart=/usr/libexec/cloudstack/cloudstack-agent-systemd-wrapper.sh
|
||||||
|
Restart=always
|
||||||
|
RestartSec=10s
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
Loading…
x
Reference in New Issue
Block a user