mirror of
https://github.com/MeiK2333/river.git
synced 2025-11-04 14:49:40 +08:00
add java language
This commit is contained in:
parent
f3cb70019b
commit
37e3017ff7
@ -20,7 +20,7 @@ RUN apt install -y gcc g++
|
||||
# install python3.8
|
||||
RUN apt install -y software-properties-common && \
|
||||
add-apt-repository -y ppa:deadsnakes/ppa && \
|
||||
apt install -y python3.8
|
||||
apt install -y python3.8 python3-pip
|
||||
|
||||
# install rust
|
||||
RUN apt install -y curl && \
|
||||
|
||||
@ -24,6 +24,7 @@ enum Language {
|
||||
Node = 4;
|
||||
TypeScript = 5;
|
||||
Go = 6;
|
||||
Java = 7;
|
||||
}
|
||||
|
||||
enum JudgeType {
|
||||
|
||||
@ -44,6 +44,7 @@ pub async fn judger(
|
||||
Some(Language::Node) => "node main.js",
|
||||
Some(Language::TypeScript) => "node main.js",
|
||||
Some(Language::Go) => "./a.out",
|
||||
Some(Language::Java) => "Main.java",
|
||||
None => return Err(Error::LanguageNotFound(request.language)),
|
||||
};
|
||||
let process = Process::new(
|
||||
@ -109,6 +110,7 @@ pub async fn compile(
|
||||
Some(Language::Node) => "main.js",
|
||||
Some(Language::TypeScript) => "main.ts",
|
||||
Some(Language::Go) => "main.go",
|
||||
Some(Language::Java) => "Main.java",
|
||||
None => return Err(Error::LanguageNotFound(request.language)),
|
||||
};
|
||||
if let Err(e) = fs::write(path.join(filename), &data.code).await {
|
||||
@ -124,6 +126,7 @@ pub async fn compile(
|
||||
Some(Language::Node) => "/usr/bin/node /plugins/js/validate.js main.js",
|
||||
Some(Language::TypeScript) => "/usr/bin/tsc main.ts",
|
||||
Some(Language::Go) => "/usr/bin/go build -ldflags \"-s -w\" main.go",
|
||||
Some(Language::Java) => "/usr/bin/java -cp . Main",
|
||||
None => return Err(Error::LanguageNotFound(request.language)),
|
||||
};
|
||||
debug!("build command: {}", cmd);
|
||||
|
||||
@ -109,7 +109,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
env_logger::init_from_env(env);
|
||||
|
||||
let addr = "127.0.0.1:4003".parse()?;
|
||||
let addr = "0.0.0.0:4003".parse()?;
|
||||
let river = RiverService::default();
|
||||
|
||||
info!("listen on: {}", addr);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user