cleanup
always show ticker update on screen rolling log to file.
This commit is contained in:
parent
8ddab27903
commit
87080bdc05
|
@ -32,8 +32,7 @@
|
|||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-freemarker:1.5.4.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.freemarker:freemarker:2.3.26-incubating" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-simple:1.6.4" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.8.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.8.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.8.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.8.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-jcl:2.8.2" level="project" />
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -46,16 +46,10 @@
|
|||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.25</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.6.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-slf4j-impl</artifactId>
|
||||
<version>2.8.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
|
|
|
@ -14,13 +14,12 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/**
|
||||
* Created by Elroy on 29-6-2017.
|
||||
|
@ -55,14 +54,9 @@ public class Application {
|
|||
return factory;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Executor taskExecutor() {
|
||||
return new SimpleAsyncTaskExecutor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TaskScheduler taskScheduler() {
|
||||
return new ConcurrentTaskScheduler();
|
||||
return new ConcurrentTaskScheduler(Executors.newScheduledThreadPool(5));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -8,6 +8,8 @@ import com.google.gson.JsonObject;
|
|||
import com.google.gson.JsonParser;
|
||||
import net.jodah.failsafe.Failsafe;
|
||||
import net.jodah.failsafe.RetryPolicy;
|
||||
import nl.komtek.gpi.utils.ProxyHandledException;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -155,7 +157,6 @@ public class GunbotProxyService {
|
|||
@Cacheable(value = "chartData", key = "#currencyPair")
|
||||
public String getChartData(String currencyPair, String start, long period) {
|
||||
|
||||
logger.debug("chartData: " + currencyPair + " -- start:" + start + " -- period:" + period);
|
||||
long startLong = 0;
|
||||
if (start.indexOf(".") > 0) {
|
||||
startLong = Long.valueOf(start.substring(0, start.indexOf(".")));
|
||||
|
@ -166,7 +167,9 @@ public class GunbotProxyService {
|
|||
while (true) {
|
||||
try {
|
||||
String result = publicClient.getChartData(currencyPair, period, startLong);
|
||||
return analyzeResult(result);
|
||||
result = analyzeResult(result);
|
||||
logger.debug("chartData: " + currencyPair + " -- start:" + start + " -- period:" + period + " -- " + result);
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
handleException(e);
|
||||
}
|
||||
|
@ -183,7 +186,12 @@ public class GunbotProxyService {
|
|||
String result = Failsafe.with(retryPolicy)
|
||||
.onFailedAttempt(this::handleException)
|
||||
.get(() -> analyzeResult(publicClient.returnTicker()));
|
||||
logger.debug("ticker: " + result);
|
||||
|
||||
if (logger.getLevel().isLessSpecificThan(Level.DEBUG)) {
|
||||
logger.info("ticker updated");
|
||||
} else {
|
||||
logger.info("ticker: " + result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -346,20 +354,20 @@ public class GunbotProxyService {
|
|||
|
||||
private String analyzeResult(String result) {
|
||||
if (result != null && result.contains("Nonce")) {
|
||||
throw new RuntimeException("nonce error: " + result);
|
||||
throw new ProxyHandledException("nonce error: " + result);
|
||||
} else if (result == null) {
|
||||
throw new RuntimeException("No value was returned");
|
||||
throw new ProxyHandledException("No value was returned");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void handleException(Throwable e) {
|
||||
if (!(e instanceof RuntimeException)) {
|
||||
logger.error(e.toString());
|
||||
if (e instanceof ProxyHandledException) {
|
||||
logger.debug(e.toString());
|
||||
} else if (e instanceof NullPointerException) {
|
||||
logger.error("Something is really wrong", e);
|
||||
} else {
|
||||
logger.debug(e.toString());
|
||||
logger.error(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package nl.komtek.gpi.utils;
|
||||
|
||||
/**
|
||||
* Created by Elroy on 05-7-2017.
|
||||
*/
|
||||
public class ProxyHandledException extends RuntimeException {
|
||||
|
||||
public ProxyHandledException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@ public class ScheduledTasks {
|
|||
@Autowired
|
||||
private GunbotProxyService gunbotProxyService;
|
||||
|
||||
@Scheduled(fixedDelay = Long.MAX_VALUE)
|
||||
@Scheduled(fixedRate = Long.MAX_VALUE)
|
||||
public void itWorks() {
|
||||
if (gunbotProxyService.isUsingMultipleMarkets()) {
|
||||
logger.info("Running in multimarket MODE!");
|
||||
|
|
|
@ -1,25 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN" monitorInterval="900">
|
||||
<Properties>
|
||||
<Property name="baseDir">logs</Property>
|
||||
</Properties>
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] %p %c{1} - %m%n"/>
|
||||
</Console>
|
||||
<File name="File" fileName="GunbotProxy.log">
|
||||
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] %p %c{1} - %m%n"/>
|
||||
</File>
|
||||
<RollingFile name="RollingFile" fileName="${baseDir}/GunbotProxy.log"
|
||||
filePattern="${baseDir}/$${date:yyyy-MM}/GunbotProxy-%d{yyyy-MM-dd}.log.gz">
|
||||
<PatternLayout pattern="%d %p %c{1.} [%t] %m%n"/>
|
||||
<CronTriggeringPolicy schedule="0 0 0 * * ?"/>
|
||||
<DefaultRolloverStrategy>
|
||||
<Delete basePath="${baseDir}" maxDepth="2">
|
||||
<IfFileName glob="*/GunbotProxy.log-*.log.gz"/>
|
||||
<IfLastModified age="1d"/>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingFile>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="nl.komtek" level="info" additivity="false">
|
||||
<AppenderRef ref="Console"/>
|
||||
<AppenderRef ref="File"/>
|
||||
<Logger name="nl.komtek" level="debug" additivity="false">
|
||||
<AppenderRef ref="Console" level="info"/>
|
||||
<AppenderRef ref="RollingFile" level="debug"/>
|
||||
</Logger>
|
||||
<Logger name="org.apache" level="error" additivity="false">
|
||||
<AppenderRef ref="Console"/>
|
||||
<AppenderRef ref="File"/>
|
||||
<AppenderRef ref="RollingFile"/>
|
||||
</Logger>
|
||||
<Root level="error">
|
||||
<AppenderRef ref="Console"/>
|
||||
<AppenderRef ref="File"/>
|
||||
<AppenderRef ref="RollingFile"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
Loading…
Reference in New Issue