Added logging (to file) and cleanup job

This commit is contained in:
Christian Basler 2015-10-14 18:33:42 +02:00
parent a35b0881b3
commit 3df853734c
3 changed files with 39 additions and 3 deletions

View File

@ -0,0 +1,28 @@
package ch.dissem.bitmessage.server;
import ch.dissem.bitmessage.BitmessageContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.TimerTask;
/**
* Created by chrigu on 04.10.15.
*/
public class CleanupJob extends TimerTask {
private static final Logger LOG = LoggerFactory.getLogger(CleanupJob.class);
private final BitmessageContext ctx;
public CleanupJob(BitmessageContext ctx) {
this.ctx = ctx;
}
@Override
public void run() {
try {
ctx.cleanup();
} catch (Throwable t) {
LOG.error("Problem while cleaning inventory", t);
}
}
}

View File

@ -41,10 +41,10 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.Timer;
@CrossOrigin
@RestController
@ -52,6 +52,8 @@ import java.util.Set;
public class JabitServerApplication {
private static final Logger LOG = LoggerFactory.getLogger(JabitServerApplication.class);
private static final long HOUR = 60 * 60 * 1000l; // in ms
private static final String CONFIG_FILE = "config.properties";
private static final String PROPERTY_PORT = "port";
@ -145,9 +147,12 @@ public class JabitServerApplication {
.networkHandler(new DefaultNetworkHandler())
.security(new BouncySecurity())
.port(port)
.listener(plaintext -> {
})
.build();
ctx.startup(plaintext -> {
});
ctx.startup();
new Timer().scheduleAtFixedRate(new CleanupJob(ctx), 1 * HOUR, 24 * HOUR);
}
public static void main(String[] args) {

View File

@ -0,0 +1,3 @@
logging.file=jabit.log
logging.level.*=ERROR
logging.level.ch.dissem.*=WARN