Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packaging/systemd/cloudstack-usage.default
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 2 additions & 1 deletion packaging/systemd/cloudstack-usage.service
Original file line number Diff line number Diff line change
Expand Up @@ -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=$$
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GabrielBrascher @andrijapanic moved the JAVA_PID here so users can't change/mess it around. The systemd variable referencing is limiting, the fix was to use the ${VAR} syntax and not $VAR syntax. Can you believe it! https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines

ExecStart=/bin/sh -ec '/usr/bin/java -Dpid=${JAVA_PID} $JAVA_OPTS $JAVA_DEBUG -cp $CLASSPATH $JAVA_CLASS'
Restart=always
RestartSec=10s

Expand Down
6 changes: 1 addition & 5 deletions usage/src/com/cloud/usage/UsageServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ public void start() {

appContext = new ClassPathXmlApplicationContext("usageApplicationContext.xml");

try {
ComponentContext.initComponentsLifeCycle();
} catch (Exception e) {
e.printStackTrace();
}
ComponentContext.initComponentsLifeCycle();

mgr = appContext.getBean(UsageManager.class);

Expand Down