修改支持跟新github
This commit is contained in:
parent
3852e4631c
commit
deace660f3
1
.gitignore
vendored
1
.gitignore
vendored
@ -49,3 +49,4 @@ target
|
||||
*.iml
|
||||
gradle
|
||||
logs
|
||||
build
|
18
build.sh
Executable file
18
build.sh
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
rm -rf ./build
|
||||
|
||||
if [ ! -d "./build" ]
|
||||
then
|
||||
mkdir build
|
||||
fi
|
||||
|
||||
mvn clean
|
||||
mvn install -Dmaven.test.skip=true
|
||||
|
||||
cp -r ./target/github_zeekling-1.0.jar ./build/
|
||||
cp -r ./start.sh ./build/
|
||||
cp -r ./src/main/resources/blog.properties ./build/
|
||||
cp -r ./src/main/resources/log4j.properties ./build/
|
||||
cp -r ./target/lib ./build/
|
||||
|
42
pom.xml
42
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.zeekling</groupId>
|
||||
<artifactId>github_zeekling</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.0</version>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@ -49,7 +49,13 @@
|
||||
<artifactId>rome</artifactId>
|
||||
<version>1.6.0</version>
|
||||
</dependency>
|
||||
<!-- Thanks for using https://jar-download.com -->
|
||||
<dependency>
|
||||
<groupId>sunjce_provider</groupId>
|
||||
<artifactId>sunjce_provider</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/src/lib/sunjce_provider.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@ -64,6 +70,38 @@
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<addClasspath>true</addClasspath>
|
||||
<classpathPrefix>lib/</classpathPrefix>
|
||||
<mainClass>com.zeekling.Main</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.10</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/lib</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
@ -2,6 +2,8 @@ package com.zeekling;
|
||||
|
||||
import com.zeekling.blog.BlogUpdateService;
|
||||
import com.zeekling.blog.BlogUpdateServiceImpl;
|
||||
import org.apache.log4j.LogManager;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* @author zeekling [lingzhaohui@zeekling.cn]
|
||||
@ -11,10 +13,17 @@ import com.zeekling.blog.BlogUpdateServiceImpl;
|
||||
*/
|
||||
public class Main {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(Main.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
BlogUpdateService updateService = new BlogUpdateServiceImpl("/home/zeek/project/github_zeekling/src/main/resources/blog.properties");
|
||||
String configPath = System.getProperty("configPath");
|
||||
BlogUpdateService updateService = new BlogUpdateServiceImpl(configPath);
|
||||
int res = updateService.update();
|
||||
System.out.println(res);
|
||||
if (res == 0){
|
||||
LOGGER.info("update github success!");
|
||||
return;
|
||||
}
|
||||
LOGGER.error("update github failed!");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ public final class GitHubs {
|
||||
final HttpResponse res = HttpRequest.get("https://hacpai.com/github/repos?id=" + githubUserId).trustAllCerts(true).
|
||||
connectionTimeout(3000).timeout(7000).header("User-Agent", GitHubConstants.USER_AGENT).send();
|
||||
if (200 != res.statusCode()) {
|
||||
LOGGER.error("error code:" + res.statusCode());
|
||||
return null;
|
||||
}
|
||||
res.charset("UTF-8");
|
||||
@ -176,12 +177,13 @@ public final class GitHubs {
|
||||
final HttpResponse response = HttpRequest.get("https://api.github.com/user").header("Authorization", "token " + pat).
|
||||
connectionTimeout(7000).timeout(30000).header("User-Agent", GitHubConstants.USER_AGENT).send();
|
||||
if (200 != response.statusCode()) {
|
||||
LOGGER.error("error code:" + response.statusCode());
|
||||
return null;
|
||||
}
|
||||
response.charset("UTF-8");
|
||||
return new JSONObject(response.bodyText());
|
||||
} catch (final Exception e) {
|
||||
LOGGER.log(Level.ERROR, "Gets GitHub user info failed: " + e.getMessage());
|
||||
LOGGER.log(Level.ERROR, "Gets GitHub user info failed: " + e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,31 @@
|
||||
### 设置###
|
||||
log4j.rootLogger = debug,stdout,D,E
|
||||
log4j.rootLogger=INFO,stdout,R, E
|
||||
|
||||
### 输出信息到控制抬 ###
|
||||
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target = System.out
|
||||
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] [%c] [%p] - %m%n
|
||||
|
||||
### 输出DEBUG 级别以上的日志到=./logs/debug.log ###
|
||||
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.D.File = ./logs/debug.log
|
||||
log4j.appender.D.Append = true
|
||||
log4j.appender.D.Threshold = DEBUG
|
||||
log4j.appender.D.layout = org.apache.log4j.PatternLayout
|
||||
log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
|
||||
log4j.appender.file = org.apache.log4j.FileAppender
|
||||
log4j.appender.file.File = ./logs/spider.log
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] [%c] [%p] - %m%n
|
||||
|
||||
### 输出ERROR 级别以上的日志到=./logs/error.log ###
|
||||
### 输出到日志文件 ###
|
||||
# 每天生成一个新的日志文件
|
||||
log4j.appender.R = org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.R.File = ./logs/log.log
|
||||
log4j.appender.R.Append = true
|
||||
# DEBUG级别及以上的日志信息输出到./logs/log.log中
|
||||
log4j.appender.R.Threshold = DEBUG
|
||||
log4j.appender.R.layout = org.apache.log4j.PatternLayout
|
||||
log4j.appender.R.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} [%t] [%c] [%p] - %m%n
|
||||
|
||||
### 保存异常信息到单独文件 ###
|
||||
# 每天生成一个新的日志文件
|
||||
log4j.appender.E = org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.E.File =./logs/error.log
|
||||
log4j.appender.E.File = ./logs/error.log
|
||||
log4j.appender.E.Append = true
|
||||
# ERROR级别及以上的日志信息输出到./logs/log.log中
|
||||
log4j.appender.E.Threshold = ERROR
|
||||
log4j.appender.E.layout = org.apache.log4j.PatternLayout
|
||||
log4j.appender.E.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
|
||||
log4j.appender.E.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} [%t] [%c] [%p] - %m%n
|
Loading…
Reference in New Issue
Block a user