Open homestar9 opened 2 months ago
Update:
If I make the following change to Line 29 of reinit.cfc:
var serverInfo = serverService.getServerInfoByDiscovery( name = arguments.name );
The reinit will work if you specify the name of the server like this:
fwreinit name=mymodule
However, I think fwreinit should be smart enough to infer the name from the current working directory server.json file or box.json, if present.
Therefore, I think the fix involves making the change I mentioned above and also changing the default name
argument in the run()
method to look for a value in the server.json file followed next by box.json.
Update 2: What about this possible solution?
/**
* Reinitialize a running ColdBox app if a server was started with CommandBox.
* This command must be ran from the root of the ColdBox Application
* .
* {code:bash}
* coldbox reinit
* {code}
* .
* {code:bash}
* coldbox reinit password="mypass"
* {code}
**/
component aliases="fwreinit" {
// DI
property name="serverService" inject="ServerService";
property name="formatter" inject="formatter";
/**
* @password The FWReinit password
* @name Name of the CommandBox server to reinit, will default to the name listed in server.json file
* @showUrl Show the Url to reinit
**/
function run(
password = "1",
name = getDefaultServerName(),
showUrl = true
){
var serverInfo = serverService.getServerInfoByDiscovery( name = arguments.name );
if ( !structCount( serverInfo ) ) {
print.boldRedLine(
"No server configurations found for '#getCWD()#' and '#arguments.name#', so have no clue what to reinit buddy!"
);
} else {
var thisURL = "#serverInfo.host#:#serverInfo.port#/?fwreinit=#arguments.password#";
if ( arguments.showUrl ) {
print.greenLine( "Hitting... #thisURL#" );
}
http result="local.results" url="#thisURL#";
if ( findNoCase( "200", local.results.statusCode ) ) {
print.boldGreenLine( "App Reinited!" );
} else {
print
.redLine( "status code: #local.results.statusCode#" )
.redline( "error detail: " & local.results.errorDetail )
.line( trim( formatter.HTML2ANSI( local.results.filecontent ) ) );
}
}
}
private function getDefaultServerName() {
return serverService.getServerInfoByDiscovery( serverConfigFile = 'server.json' ).name;
}
}
What are the steps to reproduce this issue?
web.webroot
value is set totest-harness