Changeset 53bad7e for backend/GlobeGuru-backend/src/main/java/Server.java
- Timestamp:
- 01/10/25 00:33:50 (3 weeks ago)
- Branches:
- master
- Children:
- 1c51912
- Parents:
- c164f8f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
backend/GlobeGuru-backend/src/main/java/Server.java
rc164f8f r53bad7e 28 28 import java.time.LocalDateTime; 29 29 import java.time.format.DateTimeFormatter; 30 import java.time.temporal.ChronoUnit; 30 31 import java.util.*; 31 32 import java.util.concurrent.ExecutorService; … … 34 35 35 36 public class Server { 36 37 private static final ExecutorService executorService = Executors.newFixedThreadPool(1); 37 38 public static void main(String[] args) throws IOException, SQLException { 38 39 // Start HTTP server … … 57 58 58 59 server.start(); 59 60 60 System.out.println("Server started on port 8000"); 61 62 LocalDateTime lastUpdateTime = getLastUpdateTime(); 63 LocalDateTime now = LocalDateTime.now(); 64 if (ChronoUnit.MONTHS.between(lastUpdateTime, now) >= 3) { 65 System.out.println("Automatic Update"); 66 Future<Void> future = executorService.submit(new Scraper()); 67 Server.updateLastUpdateTime(); 68 executorService.submit(() -> { 69 try { 70 future.get(); 71 } catch (Exception e) { 72 e.printStackTrace(); 73 } 74 }); 75 76 } 77 61 78 } 62 79 static class RemoveFromSavedTripsHandler implements HttpHandler {
Note:
See TracChangeset
for help on using the changeset viewer.