diff --git a/deploy/gdccloud/deploy.sh b/deploy/gdccloud/deploy.sh index de785fd..50d3d5c 100644 --- a/deploy/gdccloud/deploy.sh +++ b/deploy/gdccloud/deploy.sh @@ -18,6 +18,6 @@ fi ssh $USERSERVER "cd /tmp && rm -rf $ARTIFACT_NAME*.jar && echo `date` 'killed' >> log_$ARTIFACT_NAME" scp build/libs/$ARTIFACT_NAME-0.1.0-SNAPSHOT.jar $USERSERVER:/tmp/$ARTIFACT_NAME-0.1.0-SNAPSHOT.jar -ssh $USERSERVER -f "cd /tmp/ && /opt/jdk1.8.0_192/bin/java -jar $ARTIFACT_NAME-0.1.0-SNAPSHOT.jar -Xms 512m -Xmx 1024m --server.port=8443 --server.http.port=8080 --ng-tracker.base-url=http://193.110.3.124:8080 --ng-tracker.dev-mode=false >> /home/user/logfile_$ARTIFACT_NAME" & +ssh $USERSERVER -f "cd /tmp/ && /opt/jdk1.8.0_192/bin/java -jar $ARTIFACT_NAME-0.1.0-SNAPSHOT.jar -Xms 512m -Xmx 1024m --server.port=8443 --server.http.port=8080 --ng-tracker.base-url=http://193.110.3.124:8080 --ng-tracker.dev-mode=false --ng-tracker.driver-path=/home/user >> /home/user/logfile_$ARTIFACT_NAME" & sleep 10 echo "is deployed" \ No newline at end of file diff --git a/src/main/java/ru/ulstu/configuration/ApplicationProperties.java b/src/main/java/ru/ulstu/configuration/ApplicationProperties.java index 49efac4..a1c0ba2 100644 --- a/src/main/java/ru/ulstu/configuration/ApplicationProperties.java +++ b/src/main/java/ru/ulstu/configuration/ApplicationProperties.java @@ -23,6 +23,8 @@ public class ApplicationProperties { private String debugEmail; + private String driverPath; + public boolean isUseHttps() { return useHttps; } @@ -70,4 +72,12 @@ public class ApplicationProperties { public void setDebugEmail(String debugEmail) { this.debugEmail = debugEmail; } + + public String getDriverPath() { + return driverPath; + } + + public void setDriverPath(String driverPath) { + this.driverPath = driverPath; + } } diff --git a/src/main/java/ru/ulstu/grant/service/KiasService.java b/src/main/java/ru/ulstu/grant/service/KiasService.java index 618e83c..dbeacf5 100644 --- a/src/main/java/ru/ulstu/grant/service/KiasService.java +++ b/src/main/java/ru/ulstu/grant/service/KiasService.java @@ -5,16 +5,20 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.springframework.stereotype.Service; +import ru.ulstu.configuration.ApplicationProperties; import ru.ulstu.grant.model.GrantDto; import ru.ulstu.grant.page.KiasPage; import ru.ulstu.user.service.UserService; +import java.nio.file.Paths; import java.text.ParseException; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.List; +import static org.apache.commons.lang3.StringUtils.isEmpty; + @Service public class KiasService { private final static String BASE_URL = "https://www.rfbr.ru/rffi/ru/contest_search?CONTEST_STATUS_ID=%s&CONTEST_TYPE=%s&CONTEST_YEAR=%s"; @@ -27,9 +31,12 @@ public class KiasService { private final static String DRIVER_TYPE = "webdriver.chrome.driver"; private final UserService userService; + private final ApplicationProperties applicationProperties; - public KiasService(UserService userService) { + public KiasService(UserService userService, + ApplicationProperties applicationProperties) { this.userService = userService; + this.applicationProperties = applicationProperties; } public List getNewGrantsDto() throws ParseException { @@ -78,8 +85,10 @@ public class KiasService { } private String getDriverExecutablePath() { - return KiasService.class.getClassLoader().getResource( - String.format(DRIVER_LOCATION, getDriverExecutable(isWindows()))).getFile(); + return isEmpty(applicationProperties.getDriverPath()) + ? KiasService.class.getClassLoader() + .getResource(String.format(DRIVER_LOCATION, getDriverExecutable(isWindows()))).getFile() + : Paths.get(applicationProperties.getDriverPath(), getDriverExecutable(isWindows())).toString(); } private String getDriverExecutable(boolean isWindows) { diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index f4be778..f4d9c36 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -37,4 +37,5 @@ ng-tracker.undead-user-login=admin ng-tracker.dev-mode=true ng-tracker.debug_email= ng-tracker.use-https=false -ng-tracker.check-run=false \ No newline at end of file +ng-tracker.check-run=false +ng-tracker.driver-path= diff --git a/src/test/java/context/Context.java b/src/test/java/context/Context.java index b32c08e..474b1cb 100644 --- a/src/test/java/context/Context.java +++ b/src/test/java/context/Context.java @@ -6,8 +6,6 @@ import org.openqa.selenium.WebDriver; import java.util.concurrent.TimeUnit; -//import org.openqa.selenium.support.PageFactory; - public abstract class Context { private final static String DRIVER_LOCATION = "drivers/%s";