You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2020/06/29 20:49:54 UTC

[GitHub] [cloudstack] ravening commented on a change in pull request #4144: Fix Usage failed to get pid

ravening commented on a change in pull request #4144:
URL: https://github.com/apache/cloudstack/pull/4144#discussion_r447245386



##########
File path: usage/src/main/java/com/cloud/usage/UsageManagerImpl.java
##########
@@ -275,7 +277,14 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
             s_logger.error("Unhandled exception configuring UsageManger", e);
             throw new ConfigurationException("Unhandled exception configuring UsageManager " + e.toString());
         }
-        _pid = Integer.parseInt(System.getProperty("pid"));
+
+        try {
+            String processName = ManagementFactory.getRuntimeMXBean().getName();
+            _pid = Integer.parseInt(processName.split("@")[0]);
+        } catch (Exception e) {
+            s_logger.error("Unable to get process pid ", e);
+            throw new ConfigurationException("Unable to get process pid " + e.toString());

Review comment:
       Should we add a more meaningful message here so its more clear?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org