Skip to content

Commit

Permalink
Fix docker plugin dependency issues.
Browse files Browse the repository at this point in the history
Improve updater do it doesn't have to contain the version number.
Version 1.0.8
  • Loading branch information
lamarios committed Apr 21, 2017
1 parent 323e02b commit 3c871bc
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 47 deletions.
2 changes: 1 addition & 1 deletion updater/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>updater</artifactId>
<version>1.0.7</version>
<version>1.0.8</version>
<dependencies>

<dependency>
Expand Down
39 changes: 22 additions & 17 deletions updater/src/main/java/com/ftpix/homedash/updater/Updater.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,40 +90,45 @@ public static void main(String[] args) throws IOException, ZipException {

}


/**
* This method will stop homedash and trigger the update
*
* @param downloadPath
* @throws IOException
*/
public void stopHomedashAndTriggerUpdate(Path downloadPath) throws IOException {
if(isFolderStructureOkForAutoUpdate()) {
if (isFolderStructureOkForAutoUpdate()) {
Path pidFile = Paths.get("homedash.pid").toAbsolutePath();
Path autoUpdaterJar = downloadPath.resolve("bin/updater-"+getLatestVersion().getName()+"-jar-with-dependencies.jar").toAbsolutePath();
Path binFolder = downloadPath.resolve("bin").toAbsolutePath();
//Path autoUpdaterJar = Paths.get("/tmp/homedash-update5156811059531871535/web-1.0.3/bin/updater-" + getLatestVersion().getName() + "-jar-with-dependencies.jar");
Files.list(binFolder).filter(p -> p.getFileName().toString().startsWith("updater-")).findFirst().map(Path::toAbsolutePath).ifPresent(autoUpdaterJar -> {

logger.info("PID file :[{}]", pidFile.toString());
logger.info("Update jar [{}]", autoUpdaterJar.toString());
try {
logger.info("PID file :[{}]", pidFile.toString());
logger.info("Update jar [{}]", autoUpdaterJar.toString());

//we need to delete the pid file, start the auto updater and exit
if (Files.notExists(pidFile))
throw new FileNotFoundException("File " + pidFile.toAbsolutePath().toString() + " not found");
//we need to delete the pid file, start the auto updater and exit
if (Files.notExists(pidFile))
throw new FileNotFoundException("File " + pidFile.toAbsolutePath().toString() + " not found");

if (Files.notExists(autoUpdaterJar))
throw new FileNotFoundException("File " + autoUpdaterJar.toAbsolutePath().toString() + " not found");
if (Files.notExists(autoUpdaterJar))
throw new FileNotFoundException("File " + autoUpdaterJar.toAbsolutePath().toString() + " not found");


Files.deleteIfExists(pidFile);
Files.deleteIfExists(pidFile);


//Building the jar command with all the necessary parameters
ProcessBuilder pb = new ProcessBuilder("java", "-jar", autoUpdaterJar.toString(), downloadPath.toString(), Paths.get(".").toAbsolutePath().toString());
pb.directory(downloadPath.toAbsolutePath().toFile());
pb.start();
//Building the jar command with all the necessary parameters
ProcessBuilder pb = new ProcessBuilder("java", "-jar", autoUpdaterJar.toString(), downloadPath.toString(), Paths.get(".").toAbsolutePath().toString());
pb.directory(downloadPath.toAbsolutePath().toFile());
pb.start();

//when the process is starting, we need to exist as the updater is going to start homedash again
System.exit(0);
//when the process is starting, we need to exist as the updater is going to start homedash again
System.exit(0);
} catch (Exception e) {
logger.error("Error while updating ", e);
}
});
}
}

Expand Down
16 changes: 15 additions & 1 deletion web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<artifactId>web</artifactId>
<name>web</name>
<version>1.0.7</version>
<version>1.0.8</version>
<url>http://maven.apache.org</url>

<properties>
Expand Down Expand Up @@ -112,6 +112,20 @@
<groupId>com.ftpix.homedash</groupId>
<artifactId>updater</artifactId>
<version>LATEST</version>
<exclusions>
<exclusion>
<artifactId>jackson-annotations</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
</exclusion>
<exclusion>
<artifactId>jackson-core</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
</exclusion>
<exclusion>
<artifactId>jackson-databind</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
</exclusion>
</exclusions>
</dependency>

<!-- plugins -->
Expand Down
58 changes: 30 additions & 28 deletions web/src/main/java/com/ftpix/homedash/app/Constants.java
Original file line number Diff line number Diff line change
@@ -1,45 +1,47 @@
package com.ftpix.homedash.app;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ResourceBundle;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;



public class Constants {
public final static String CACHE_FOLDER;
public final static String DB_PATH;
public final static int PORT;
public final static String SALT;
private static Logger logger = LogManager.getLogger();

static {
logger.info("Loading conf file");
ResourceBundle rs = ResourceBundle.getBundle("homedash");

String path = rs.getString("cache_path");
public final static String CACHE_FOLDER;
public final static String DB_PATH;
public final static int PORT;
public final static String SALT;
private static Logger logger = LogManager.getLogger();

static {

logger.info("Loading conf file");
ResourceBundle rs = ResourceBundle.getBundle("homedash");

String path = rs.getString("cache_path");
if (!path.endsWith("/")) {
path += "/";
}
path += "/";
}

CACHE_FOLDER = path;

CACHE_FOLDER = path;
DB_PATH = rs.getString("db_path");

DB_PATH = rs.getString("db_path");
PORT = Integer.parseInt(rs.getString("port"));

PORT = Integer.parseInt(rs.getString("port"));
File f = new File(CACHE_FOLDER);
if (!f.exists()) {
f.mkdirs();
}

File f = new File(CACHE_FOLDER);
if (!f.exists()) {
f.mkdirs();
}
SALT = rs.getString("salt");

SALT = rs.getString("salt");

logger.info("DB_PATH:{}", DB_PATH);
logger.info("Cache folder:{}", CACHE_FOLDER);
logger.info("Port", PORT);
}
logger.info("DB_PATH:{}", DB_PATH);
logger.info("Cache folder:{}", CACHE_FOLDER);
logger.info("Port", PORT);
}
}

0 comments on commit 3c871bc

Please sign in to comment.