fixes for server, added onefetch
parent
961a688068
commit
82b0348feb
|
|
@ -19,4 +19,5 @@ You don't need to do both of these steps. The control panel runs the other serve
|
|||
3. Install rust: `sudo apt install cargo`
|
||||
3. Switch to control panel: `cd control-panel`
|
||||
5. Build: `cargo build --release`
|
||||
6. Run the web server in the background so that it doesn't quit when you leave ssh: `nohup sudo ./target/release/control-panel`. You'll have to install `nohup` with apt.
|
||||
6. `touch ../nohup.out ../restarts.log`
|
||||
6. Run the web server in the background so that it doesn't quit when you leave ssh: `nohup sudo ./target/release/control-panel`. You'll have to install `nohup` with apt.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"port":80,
|
||||
"port":5000,
|
||||
"tcp_timeout":30,
|
||||
"tcp_send_buffer":100000
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,3 +4,4 @@ main
|
|||
main.exe
|
||||
main.pdb
|
||||
.idea/
|
||||
onefetch.out
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
sudo -u ubuntu bash -c "onefetch > onefetch.out"
|
||||
|
|
@ -31,7 +31,6 @@ fn lines_from_file(filename: impl AsRef<Path>) -> Vec<String> {
|
|||
.collect()
|
||||
}
|
||||
|
||||
// Macro documentation can be found in the actix_web_codegen crate
|
||||
#[get("/")]
|
||||
async fn index(hb: web::Data<Handlebars<'_>>) -> HttpResponse {
|
||||
|
||||
|
|
@ -47,11 +46,20 @@ async fn index(hb: web::Data<Handlebars<'_>>) -> HttpResponse {
|
|||
.output()
|
||||
.expect("failed to execute process");
|
||||
|
||||
let _onefetch = Command::new("sh")
|
||||
.arg("onefetch_file.sh")
|
||||
.output()
|
||||
.expect("failed");
|
||||
|
||||
let onefetch = fs::read_to_string("onefetch.out").unwrap();
|
||||
|
||||
|
||||
let data = json!({
|
||||
"log_output": log_file,
|
||||
"restarts_output": restarts_log,
|
||||
"uptime": format!("{}", String::from_utf8_lossy(&uptime.stdout)),
|
||||
//"onefetch": format!("{}", String::from_utf8_lossy(&onefetch.stdout))
|
||||
"onefetch": onefetch
|
||||
});
|
||||
let body = hb.render("index", &data).unwrap();
|
||||
|
||||
|
|
@ -65,8 +73,8 @@ async fn restart_server() -> HttpResponse {
|
|||
let _output = Command::new("sh")
|
||||
.arg("../run.sh")
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
//.stdout(Stdio::null())
|
||||
//.stderr(Stdio::null())
|
||||
.spawn();
|
||||
|
||||
HttpResponse::Ok().body("DONE")
|
||||
|
|
@ -98,11 +106,15 @@ async fn compile() -> HttpResponse {
|
|||
let root = Path::new(&config.server_dir);
|
||||
let _new_dir = env::set_current_dir(&root);
|
||||
|
||||
print!("before");
|
||||
|
||||
let output = Command::new("cargo")
|
||||
.arg("build")
|
||||
.arg("--release")
|
||||
.output()
|
||||
.expect("failed to execute process");
|
||||
|
||||
print!("after");
|
||||
|
||||
let _new_dir = env::set_current_dir(orig_dir);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
<body>
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<img src="https://vel.engr.uga.edu/wp-content/uploads/elementor/thumbs/4dLogo-1-oaxk7d2mcrutzo0dhqah6qlgpp2c1tvihad1dchrc0.png" style="float: right;">
|
||||
<h1 class="title">
|
||||
VelNet Control Panel
|
||||
</h1>
|
||||
|
|
@ -42,6 +43,7 @@
|
|||
<button class="button" id="compile-button">Compile</button>
|
||||
</div>
|
||||
<div class="block">Uptime: {{uptime}}</div>
|
||||
<pre>{{onefetch}}</pre>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
|
@ -113,4 +115,4 @@
|
|||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
|||
18
run.sh
18
run.sh
|
|
@ -1,13 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
# pushd $BASEDIR
|
||||
echo $(date +"%Y-%m-%dT%T.%3N%z") >> $BASEDIR/restarts.log
|
||||
echo "Before: "
|
||||
pgrep VelNetServer
|
||||
pkill VelNetServer
|
||||
echo "\nAfter: "
|
||||
pgrep VelNetServer
|
||||
echo "Before: " >> $BASEDIR/restarts.log
|
||||
pgrep -f "VelNetServerRust -v2" >> $BASEDIR/restarts.log
|
||||
#pgrep -f "VelNetServerRust -v2" | xargs sudo kill >> $BASEDIRE/restarts.log
|
||||
#kill $(pgrep -f "VelNetServerRust -v2")
|
||||
pkill -f "VelNetServerRust -v2"
|
||||
echo "\nAfter: " >> $BASEDIR/restarts.log
|
||||
pgrep -f "VelNetServerRust -v2" >> $BASEDIR/restarts.log
|
||||
echo "\n"
|
||||
(cd $BASEDIR && nohup "./target/release/VelNetServerRust" &)
|
||||
(cd $BASEDIR && nohup ./target/release/VelNetServerRust -v2 >> nohup.out &)
|
||||
# nohup "$BASEDIR/target/release/VelNetServerRust" &
|
||||
echo "Starting..." >> $BASEDIR/restarts.log
|
||||
# popd $BASEDIR
|
||||
Loading…
Reference in New Issue