This is an automated email from the ASF dual-hosted git repository.
gabriel pushed a commit to branch 4.11
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.11 by this push:
new f7327c7 systemd: Fix -Dpid arg passing to systemd usage service
(#3210)
f7327c7 is described below
commit f7327c745768f27ccfe90bf7b52b7b2fccaff59d
Author: Rohit Yadav <[email protected]>
AuthorDate: Thu Mar 14 17:49:12 2019 +0530
systemd: Fix -Dpid arg passing to systemd usage service (#3210)
* systemd: Fix -Dpid arg passing to systemd usage service
This fixes regression introduced by refactoring PR #3163 where `-Dpid`
was incorrectly passed string `$$` instead of parent PID integer.
Signed-off-by: Rohit Yadav <[email protected]>
* fix systemd limitation, exec using /bin/sh instead and wrap in ${} syntax
https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines
Signed-off-by: Rohit Yadav <[email protected]>
* usage: don't hide exception from Gabriel's
https://github.com/apache/cloudstack/pull/3207/files#diff-062fcf5ae32de59dfd6cd4f780e1d7cd
Signed-off-by: Rohit Yadav <[email protected]>
---
packaging/systemd/cloudstack-usage.default | 5 ++++-
packaging/systemd/cloudstack-usage.service | 3 ++-
usage/src/com/cloud/usage/UsageServer.java | 6 +-----
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/packaging/systemd/cloudstack-usage.default
b/packaging/systemd/cloudstack-usage.default
index 26f5528..089f3ee 100644
--- a/packaging/systemd/cloudstack-usage.default
+++ b/packaging/systemd/cloudstack-usage.default
@@ -15,8 +15,11 @@
# specific language governing permissions and limitations
# under the License.
-JAVA_OPTS="-Dpid=$$ -Xms256m -Xmx2048m"
+JAVA_OPTS="-Xms256m -Xmx2048m"
CLASSPATH="/usr/share/cloudstack-usage/*:/usr/share/cloudstack-usage/lib/*:/usr/share/cloudstack-mysql-ha/lib/*:/etc/cloudstack/usage:/usr/share/java/mysql-connector-java.jar"
JAVA_CLASS=com.cloud.usage.UsageServer
+
+# Enable the following to enable remote socket based debugging:
+#JAVA_DEBUG="-agentlib:jdwp=transport=dt_socket,address=8001,server=y,suspend=n"
diff --git a/packaging/systemd/cloudstack-usage.service
b/packaging/systemd/cloudstack-usage.service
index f887486..8d9dff2 100644
--- a/packaging/systemd/cloudstack-usage.service
+++ b/packaging/systemd/cloudstack-usage.service
@@ -24,7 +24,8 @@ After=network.target network-online.target
[Service]
Type=simple
EnvironmentFile=/etc/default/cloudstack-usage
-ExecStart=/usr/bin/java $JAVA_OPTS -cp $CLASSPATH $JAVA_CLASS
+Environment=JAVA_PID=$$
+ExecStart=/bin/sh -ec '/usr/bin/java -Dpid=${JAVA_PID} $JAVA_OPTS $JAVA_DEBUG
-cp $CLASSPATH $JAVA_CLASS'
Restart=always
RestartSec=10s
diff --git a/usage/src/com/cloud/usage/UsageServer.java
b/usage/src/com/cloud/usage/UsageServer.java
index df3f374..5e8a69d 100644
--- a/usage/src/com/cloud/usage/UsageServer.java
+++ b/usage/src/com/cloud/usage/UsageServer.java
@@ -51,11 +51,7 @@ public class UsageServer implements Daemon {
appContext = new
ClassPathXmlApplicationContext("usageApplicationContext.xml");
- try {
- ComponentContext.initComponentsLifeCycle();
- } catch (Exception e) {
- e.printStackTrace();
- }
+ ComponentContext.initComponentsLifeCycle();
mgr = appContext.getBean(UsageManager.class);