Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed symbol errors #3

Merged
merged 2 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Usage: xunlei [OPTIONS] <COMMAND>
Commands:
install Install xunlei
uninstall Uninstall xunlei
execute Execute xunlei
launch Launch xunlei
help Print this message or the help of the given subcommand(s)

Options:
Expand All @@ -34,10 +34,10 @@ Options:
-d, --download-path <DOWNLOAD_PATH> Xunlei download directory [default: /tmp/downloads]
-h, --help Print help

❯ ./xunlei execute --help
Execute xunlei
❯ ./xunlei launch --help
Launch xunlei

Usage: xunlei execute [OPTIONS]
Usage: xunlei launch [OPTIONS]

Options:
-d, --debug Enable debug mode
Expand All @@ -63,5 +63,5 @@ bash +x ./unpack.sh && cargo build --release --features embed && mv target/relea
# 执行安装
./xunlei install
# 若系统不支持systemctl,则手动启动daemon
./xunlei exectute
./xunlei launch
```
2 changes: 1 addition & 1 deletion src/launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl XunleiLauncher {
}

impl Running for XunleiLauncher {
fn execute(&self) -> anyhow::Result<()> {
fn launch(&self) -> anyhow::Result<()> {
use std::thread::{Builder, JoinHandle};
let envs = self.envs();
let mut backend_process = XunleiLauncher::run_backend(envs.clone())?;
Expand Down
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ fn main() -> anyhow::Result<()> {
match opt.commands {
#[cfg(feature = "systemd")]
Commands::Install(config) => {
systemd::XunleiInstall::from(config).execute()?;
systemd::XunleiInstall::from(config).launch()?;
}
#[cfg(feature = "systemd")]
Commands::Uninstall => {
systemd::XunleiUninstall {}.execute()?;
systemd::XunleiUninstall {}.launch()?;
}
#[cfg(feature = "launch")]
Commands::Launch(config) => {
launch::XunleiLauncher::from(config).execute()?;
launch::XunleiLauncher::from(config).launch()?;
}
}
Ok(())
Expand Down Expand Up @@ -107,5 +107,5 @@ pub(crate) fn parser_port_in_range(s: &str) -> anyhow::Result<u16> {
}

pub trait Running {
fn execute(&self) -> anyhow::Result<()>;
fn launch(&self) -> anyhow::Result<()>;
}
10 changes: 5 additions & 5 deletions src/systemd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl XunleiInstall {
Ok(std::env::current_exe()?)
}

fn systemd(&self, execute: PathBuf) -> anyhow::Result<()> {
fn systemd(&self, launch: PathBuf) -> anyhow::Result<()> {
if Systemd::support().not() {
return Ok(());
}
Expand All @@ -205,15 +205,15 @@ impl XunleiInstall {

[Service]
Type=simple
ExecStart={} execute {} -p {} -d {} -c {}
ExecStart={} launch {} -p {} -d {} -c {}
LimitNOFILE=1024
LimitNPROC=512
User={}

[Install]
WantedBy=multi-user.target"#,
self.description,
execute.display(),
launch.display(),
internal,
self.port,
self.download_path.display(),
Expand All @@ -235,7 +235,7 @@ impl XunleiInstall {
}

impl Running for XunleiInstall {
fn execute(&self) -> anyhow::Result<()> {
fn launch(&self) -> anyhow::Result<()> {
self.config()?;
self.systemd(self.install()?)
}
Expand Down Expand Up @@ -263,7 +263,7 @@ impl XunleiUninstall {
}

impl Running for XunleiUninstall {
fn execute(&self) -> anyhow::Result<()> {
fn launch(&self) -> anyhow::Result<()> {
if Systemd::support() {
Systemd::systemctl(["disable", standard::APP_NAME])?;
Systemd::systemctl(["stop", standard::APP_NAME])?;
Expand Down