oopsie
This commit is contained in:
parent
e350b039d2
commit
2789603657
@ -25,5 +25,8 @@ WORKDIR /home/container
|
|||||||
# Copy the built jar file from the builder stage
|
# Copy the built jar file from the builder stage
|
||||||
COPY --from=builder /home/container/target/PIA-Servers.jar .
|
COPY --from=builder /home/container/target/PIA-Servers.jar .
|
||||||
|
|
||||||
|
# Copy the old servers.json file
|
||||||
|
COPY --from=builder /home/container/servers.json .
|
||||||
|
|
||||||
# Run the jar file
|
# Run the jar file
|
||||||
CMD java -jar PIA-Servers.jar -Djava.awt.headless=true
|
CMD java -jar PIA-Servers.jar -Djava.awt.headless=true
|
@ -27,12 +27,13 @@ public class PiaManager {
|
|||||||
private static final String PIA_OPENVPN_CONFIGS_URL = "https://www.privateinternetaccess.com/openvpn/openvpn.zip";
|
private static final String PIA_OPENVPN_CONFIGS_URL = "https://www.privateinternetaccess.com/openvpn/openvpn.zip";
|
||||||
private static final long REMOVAL_THRESHOLD = TimeUnit.DAYS.toMicros(14); // 2 weeks
|
private static final long REMOVAL_THRESHOLD = TimeUnit.DAYS.toMicros(14); // 2 weeks
|
||||||
public static Set<PiaServer> SERVERS = new HashSet<>();
|
public static Set<PiaServer> SERVERS = new HashSet<>();
|
||||||
|
private static Path README_PATH;
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public PiaManager() {
|
public PiaManager() {
|
||||||
File serversFile = new File("servers.json");
|
File serversFile = new File("servers.json");
|
||||||
if (!serversFile.exists()) {
|
if (!serversFile.exists()) {
|
||||||
System.out.println("serversFile.json does not exist, creating...");
|
System.out.println("servers.json does not exist, creating...");
|
||||||
serversFile.createNewFile();
|
serversFile.createNewFile();
|
||||||
}
|
}
|
||||||
// Load the serversFile from the file
|
// Load the serversFile from the file
|
||||||
@ -43,16 +44,22 @@ public class PiaManager {
|
|||||||
|
|
||||||
GitUtils.cloneRepo(); // Clone the repository
|
GitUtils.cloneRepo(); // Clone the repository
|
||||||
|
|
||||||
|
// Update the servers every 5 minutes
|
||||||
new Timer().scheduleAtFixedRate(new TimerTask() {
|
new Timer().scheduleAtFixedRate(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
updateServers(serversFile); // Update the servers
|
updateServers(serversFile); // Update the servers
|
||||||
Path readmePath = ReadMeManager.updateReadme(); // Update the README.md
|
README_PATH = ReadMeManager.updateReadme(); // Update the README.md
|
||||||
|
|
||||||
// Commit the changes to the git repository
|
|
||||||
GitUtils.commitFiles("Scheduled update", serversFile.toPath(), readmePath);
|
|
||||||
}
|
}
|
||||||
}, 0, TimeUnit.MINUTES.toMillis(5));
|
}, 0, TimeUnit.MINUTES.toMillis(5));
|
||||||
|
|
||||||
|
// Commit the files every hour
|
||||||
|
new Timer().scheduleAtFixedRate(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
GitUtils.commitFiles("Scheduled update", serversFile.toPath(), README_PATH); // Commit the files
|
||||||
|
}
|
||||||
|
}, 0, TimeUnit.HOURS.toMillis(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
|
Loading…
Reference in New Issue
Block a user