added base p2prc instruction~
This commit is contained in:
@@ -4,6 +4,7 @@ use std::process::Command;
|
|||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
use crate::p2prc::*;
|
||||||
|
|
||||||
// Struct representing NodeInfo
|
// Struct representing NodeInfo
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -72,26 +73,27 @@ fn spin_process(mut process: Process) -> Process {
|
|||||||
|
|
||||||
// Main function
|
// Main function
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Starting SpinProcess...");
|
println!("{}", p2prc_map_port_command("3000", "0.0.0.0"));
|
||||||
|
// println!("Starting SpinProcess...");
|
||||||
let node_info = NodeInfo {
|
//
|
||||||
ipv4: "192.168.1.20".to_string(),
|
// let node_info = NodeInfo {
|
||||||
server_port: "9000".to_string(),
|
// ipv4: "192.168.1.20".to_string(),
|
||||||
};
|
// server_port: "9000".to_string(),
|
||||||
|
// };
|
||||||
let process = Process {
|
//
|
||||||
id: String::new(),
|
// let process = Process {
|
||||||
internal_port_no: "".to_string(),
|
// id: String::new(),
|
||||||
external_address: "".to_string(),
|
// internal_port_no: "".to_string(),
|
||||||
node_id: "Test".to_string(),
|
// external_address: "".to_string(),
|
||||||
task_name: "ExampleTask".to_string(),
|
// node_id: "Test".to_string(),
|
||||||
command_to_run_script: "./run_script.sh".to_string(),
|
// task_name: "ExampleTask".to_string(),
|
||||||
command_to_kill_script: "./kill_script.sh".to_string(),
|
// command_to_run_script: "./run_script.sh".to_string(),
|
||||||
status: false,
|
// command_to_kill_script: "./kill_script.sh".to_string(),
|
||||||
domain_name: "example.com".to_string(),
|
// status: false,
|
||||||
};
|
// domain_name: "example.com".to_string(),
|
||||||
|
// };
|
||||||
let updated = spin_process(process);
|
//
|
||||||
|
// let updated = spin_process(process);
|
||||||
println!("Final Process: {:?}", updated);
|
//
|
||||||
|
// println!("Final Process: {:?}", updated);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
use std::io::Error;
|
||||||
|
use std::process::{Command, Output};
|
||||||
|
|
||||||
|
// Runs p2prc with custom arguments called.
|
||||||
|
pub fn run_p2prc_command(arguments: &str) -> Result<Output, std::io::Error> {
|
||||||
|
Command::new("p2prc")
|
||||||
|
.arg(arguments)
|
||||||
|
.output()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Runs p2prc map port command
|
||||||
|
pub fn p2prc_map_port_command(local_port_no: &str, address: &str) -> String{
|
||||||
|
let output = run_p2prc_command(&*"--ls".to_string());
|
||||||
|
let stdout = String::from_utf8_lossy(&output.unwrap().stdout).to_string();
|
||||||
|
stdout
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user