Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) [2016-2022] Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) [2016-2025] Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -42,6 +42,9 @@
import com.sun.enterprise.module.bootstrap.StartupContext;
import fish.payara.internal.api.PostBootRunLevel;
import fish.payara.boot.runtime.BootCommands;
import org.glassfish.api.event.EventListener;
import org.glassfish.api.event.EventTypes;
import org.glassfish.api.event.Events;
import org.glassfish.embeddable.CommandRunner;
import org.glassfish.hk2.api.PostConstruct;
import org.glassfish.hk2.runlevel.RunLevel;
Expand All @@ -56,7 +59,7 @@

@Service
@RunLevel(value = PostBootRunLevel.VAL)
public class BootCommandService implements PostConstruct {
public class BootCommandService implements PostConstruct, EventListener {

private static final Logger LOGGER = Logger.getLogger(BootCommandService.class.getName());

Expand All @@ -66,6 +69,9 @@ public class BootCommandService implements PostConstruct {
@Inject
CommandRunner commandRunner;

@Inject
private Events events;

/**
* Runs a series of commands from a file
* @param file
Expand All @@ -86,8 +92,15 @@ public void doBootCommands(String file, boolean expandValues) {
}
}

@Override
public void event(Event<?> event) {
if (event.is(EventTypes.SERVER_READY)) {
doBootCommands(startupContext.getArguments().getProperty("-postbootcommandfile"), true);
}
}

@Override
public void postConstruct() {
doBootCommands(startupContext.getArguments().getProperty("-postbootcommandfile"), true);
events.register(this);
}
Comment on lines +95 to 105
Copy link
Member

Choose a reason for hiding this comment

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

See my other comment regarding sequencing.
This will likely reintroduce race conditions and sequencing issues: the postboot config file would be executed after all but new applications in the deploy dir have been deployed. Tying this service to an event rather than a specific run level will also mean that it races against all other services reacting to that event.

}