Skip to content

Commit

Permalink
Merge pull request #42 from lodygens/11.5.0
Browse files Browse the repository at this point in the history
worker tmp dir sikves issue #30
  • Loading branch information
lodygens committed Dec 5, 2017
2 parents f40f23f + 8d73ea7 commit 7d17f88
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/main/java/xtremweb/common/HTTPLauncher.java
Expand Up @@ -105,11 +105,11 @@ private HTTPLauncher(final String[] a) {
final File rootDir = config.getConfigFile().getParentFile().getParentFile();
File libDir = new File(rootDir, "lib");
if (!libDir.exists()) {
libDir = new File(System.getProperty(XWPropertyDefs.TMPDIR.toString()));
libDir = config.getTmpDir();
}
File binDir = new File(rootDir, "bin");
if (!binDir.exists()) {
binDir = new File(System.getProperty(XWPropertyDefs.TMPDIR.toString()));
binDir = config.getTmpDir();
}

while (true) {
Expand Down Expand Up @@ -191,7 +191,7 @@ private HTTPLauncher(final String[] a) {
logger.config("jarFile = " + jarFile.getCanonicalPath());
Thread.sleep(SLEEPDELAY);

tmpPath = config.getProperty(XWPropertyDefs.TMPDIR);
tmpPath = config.getTmpDir().getCanonicalPath();
jarFilePath = jarFile.getCanonicalPath();
keystorePath = config.getProperty(XWPropertyDefs.SSLKEYSTORE);
configPath = config.getProperty(XWPropertyDefs.CONFIGFILE);
Expand Down
28 changes: 22 additions & 6 deletions src/main/java/xtremweb/common/XWConfigurator.java
Expand Up @@ -555,6 +555,8 @@ public LoggerLevel getLoggerLevel() {
public XWConfigurator() {
super();

defaults = new Properties();

setProperty(XWPropertyDefs.LOGGERLEVEL);

logger = new Logger(this);
Expand Down Expand Up @@ -1030,7 +1032,7 @@ private void refresh(final boolean firstTime)
binCachedPath = getCacheDir().getCanonicalPath() + File.separator + "bin";
XWTools.checkDir(binCachedPath);
} catch (final Exception e) {
setProperty(XWPropertyDefs.TMPDIR, System.getProperty(XWPropertyDefs.JAVATMPDIR));
//setProperty(XWPropertyDefs.TMPDIR, System.getProperty(XWPropertyDefs.JAVATMPDIR));
setTmpDir(System.getProperty(XWPropertyDefs.JAVATMPDIR));
}
try {
Expand Down Expand Up @@ -1413,15 +1415,29 @@ public void setTmpDir(final File dir) throws IOException {
_host.setTotalTmp(dir.getTotalSpace() / XWTools.ONEMEGABYTES);
_host.setFreeTmp(dir.getFreeSpace() / XWTools.ONEMEGABYTES);
dir.deleteOnExit();

setProperty(XWPropertyDefs.TMPDIR, dir.getAbsolutePath());
this.defaults.put(XWPropertyDefs.TMPDIR, dir.getAbsolutePath());
// setProperty(XWPropertyDefs.TMPDIR, dir.getAbsolutePath());
}

/**
* This retrieves the default temp dir
*/
public File getTmpDir() {
return new File(getProperty(XWPropertyDefs.TMPDIR));
// return new File(getProperty(XWPropertyDefs.TMPDIR));
try {
return new File(defaults.getProperty(XWPropertyDefs.TMPDIR.toString()));
}
catch(final Exception e) {
}
try {
setTmpDir(System.getProperty(XWPropertyDefs.JAVATMPDIR));
return new File(System.getProperty(XWPropertyDefs.JAVATMPDIR));
}
catch(final Exception e) {
logger.exception("can't set tmp dir", e);
logger.fatal("can't setTmpDir");
}
return null;
}

/**
Expand Down Expand Up @@ -2230,8 +2246,8 @@ public void store(final String header, final File out) {
logger.config("Don't write config ; FORCENEWUID == " + getBoolean(XWPropertyDefs.FORCENEWUID));
return;
}
try {
store(new FileOutputStream(out), header);
try (final FileOutputStream o = new FileOutputStream(out)){
store(o, header);
} catch (final Exception e) {
logger.exception("Can't store config", e);
}
Expand Down

0 comments on commit 7d17f88

Please sign in to comment.