...
This commit is contained in:
23
deploy
Normal file
23
deploy
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
if [[ "$1" == "a" ]]
|
||||||
|
then
|
||||||
|
ssh acern mkdir -p /tmp/victorinix
|
||||||
|
rsync -rv --exclude="target" ./* acern:/tmp/victorinix/
|
||||||
|
path=$(ssh acern nix build /tmp/victorinix#webfiles -L --print-out-paths)
|
||||||
|
|
||||||
|
echo doneeeeeeeeeeeeeee
|
||||||
|
echo path: $path
|
||||||
|
|
||||||
|
scp -r acern:$path/* ocih:host/webserver/webfiles
|
||||||
|
else
|
||||||
|
path=$(nix build .#webfiles -L -v --print-out-paths $@)
|
||||||
|
|
||||||
|
echo doneeeeeeeeeeeeeee
|
||||||
|
echo path: $path
|
||||||
|
|
||||||
|
scp -r $path/* ocih:host/webserver/webfiles
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -36,6 +36,9 @@ let
|
|||||||
|
|
||||||
in {
|
in {
|
||||||
############################## PACKAGES ##############################
|
############################## PACKAGES ##############################
|
||||||
|
|
||||||
|
webfiles = pkgs.callPackage ./webfiles.nix { inherit inputs nixpkgs self; };
|
||||||
|
|
||||||
packages.default = osCrane.buildPackage {
|
packages.default = osCrane.buildPackage {
|
||||||
src = "${self}";
|
src = "${self}";
|
||||||
cargoExtraArgs = "--bin mize --features os-binary";
|
cargoExtraArgs = "--bin mize --features os-binary";
|
||||||
|
|||||||
2
modules
2
modules
Submodule modules updated: a605c0efb1...40062ee4b1
@@ -8,7 +8,7 @@ use tracing::{debug, error, info, trace, warn, Instrument};
|
|||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use std::path::Path;
|
use std::path::{Path, PathBuf};
|
||||||
use interner::shared::{VecStringPool, StringPool};
|
use interner::shared::{VecStringPool, StringPool};
|
||||||
|
|
||||||
|
|
||||||
@@ -290,7 +290,12 @@ impl Instance {
|
|||||||
|
|
||||||
pub fn load_module(&mut self, name: &str) -> MizeResult<()> {
|
pub fn load_module(&mut self, name: &str) -> MizeResult<()> {
|
||||||
// platform specific init code
|
// platform specific init code
|
||||||
crate::platform::any::load_module(self, name)
|
crate::platform::any::load_module(self, name, None)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn load_module_at(&mut self, name: &str, path: PathBuf) -> MizeResult<()> {
|
||||||
|
// platform specific init code
|
||||||
|
crate::platform::any::load_module(self, name, Some(path))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn namespace_from_string(&self, ns_str: String) -> MizeResult<Namespace> {
|
pub fn namespace_from_string(&self, ns_str: String) -> MizeResult<Namespace> {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ pub use core::instance::module::Module;
|
|||||||
pub use core::instance::Instance;
|
pub use core::instance::Instance;
|
||||||
pub use core::error::MizeError;
|
pub use core::error::MizeError;
|
||||||
pub use core::error::MizeResult;
|
pub use core::error::MizeResult;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
// platform specific stuff
|
// platform specific stuff
|
||||||
pub mod platform {
|
pub mod platform {
|
||||||
@@ -52,6 +53,6 @@ pub mod platform {
|
|||||||
pub fn instance_init(instance: &mut core::instance::Instance) {}
|
pub fn instance_init(instance: &mut core::instance::Instance) {}
|
||||||
|
|
||||||
|
|
||||||
pub fn load_module(instance: &mut core::instance::Instance, name: &str) -> MizeResult<()> { Ok(()) }
|
pub fn load_module(instance: &mut core::instance::Instance, name: &str, path: Option<PathBuf>) -> MizeResult<()> { Ok(()) }
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use clap::ArgMatches;
|
use clap::ArgMatches;
|
||||||
use home::home_dir;
|
use home::home_dir;
|
||||||
|
use crossbeam::channel::bounded;
|
||||||
|
|
||||||
use mize::error::{IntoMizeResult, MizeError, MizeResult, MizeResultTrait};
|
use mize::error::{IntoMizeResult, MizeError, MizeResult, MizeResultTrait};
|
||||||
use mize::instance::Instance;
|
use mize::instance::Instance;
|
||||||
@@ -131,7 +132,11 @@ pub fn stop(sub_matches: &ArgMatches) -> MizeResult<()> {
|
|||||||
|
|
||||||
|
|
||||||
pub fn gui(sub_matches: &ArgMatches) -> MizeResult<()> {
|
pub fn gui(sub_matches: &ArgMatches) -> MizeResult<()> {
|
||||||
let instance = Instance::with_config(config_from_cli_args(sub_matches)?)?;
|
let mut instance = Instance::with_config(config_from_cli_args(sub_matches)?)?;
|
||||||
|
|
||||||
|
instance.load_module("mme")?;
|
||||||
|
|
||||||
|
instance.wait();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,7 +166,6 @@ fn cli_matches() -> clap::ArgMatches {
|
|||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
Command::new("gui")
|
Command::new("gui")
|
||||||
.aliases(["g"])
|
|
||||||
)
|
)
|
||||||
.arg_required_else_help(true);
|
.arg_required_else_help(true);
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use std::env::VarError;
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use tracing::{debug, error, info, trace, warn};
|
use tracing::{debug, error, info, trace, warn};
|
||||||
use clap::ArgMatches;
|
use clap::ArgMatches;
|
||||||
use std::path::Path;
|
use std::path::{Path, PathBuf};
|
||||||
use std::time::UNIX_EPOCH;
|
use std::time::UNIX_EPOCH;
|
||||||
|
|
||||||
use crate::id::MizeId;
|
use crate::id::MizeId;
|
||||||
@@ -96,37 +96,49 @@ pub fn os_instance_init(instance: &mut Instance) -> MizeResult<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn seconds_since_modification(path: &Path) -> u64 {
|
pub fn seconds_since_modification(path: &Path) -> MizeResult<u64> {
|
||||||
let metadata = match fs::metadata(path) {
|
let metadata = fs::metadata(path)?;
|
||||||
Err(_) => { return u64::MAX; }, // we are the older file, if it fails
|
|
||||||
Ok(data) => data,
|
|
||||||
};
|
|
||||||
|
|
||||||
let modified = match metadata.modified() {
|
let modified = metadata.modified()?;
|
||||||
Err(_) => { return u64::MAX; }, // we are the older file, if it fails
|
|
||||||
Ok(data) => data,
|
|
||||||
};
|
|
||||||
|
|
||||||
let duration = match modified.duration_since(UNIX_EPOCH) {
|
let duration = modified.duration_since(UNIX_EPOCH)?;
|
||||||
Err(_) => { return u64::MAX; }, // we are the older file, if it fails
|
|
||||||
Ok(data) => data,
|
|
||||||
};
|
|
||||||
|
|
||||||
duration.as_secs()
|
Ok(duration.as_secs())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_module(instance: &mut Instance, name: &str) -> MizeResult<()> {
|
fn get_correct_module_path(module_dir: &Path, name: &str) -> MizeResult<PathBuf> {
|
||||||
|
let mut release_path = module_dir.join("modules").join(name).join("target").join("release").join(format!("libmize_module_{}.so", name));
|
||||||
|
let mut debug_path = module_dir.join("modules").join(name).join("target").join("debug").join(format!("libmize_module_{}.so", name));
|
||||||
|
|
||||||
|
if !release_path.exists() && !debug_path.exists() {
|
||||||
|
release_path = module_dir.join("modules").join(name).join("target").join("release").join(format!("lib{}.so", name));
|
||||||
|
debug_path = module_dir.join("modules").join(name).join("target").join("debug").join(format!("lib{}.so", name));
|
||||||
|
}
|
||||||
|
|
||||||
|
let release_modtime = match seconds_since_modification(&release_path) {
|
||||||
|
Ok(secs) => secs,
|
||||||
|
Err(e) => { return Ok(debug_path); },
|
||||||
|
};
|
||||||
|
|
||||||
|
let debug_modtime = match seconds_since_modification(&debug_path) {
|
||||||
|
Ok(secs) => secs,
|
||||||
|
Err(e) => { return Ok(release_path); },
|
||||||
|
};
|
||||||
|
|
||||||
|
if seconds_since_modification(&release_path)? > seconds_since_modification(&debug_path)? {
|
||||||
|
return Ok(debug_path);
|
||||||
|
} else {
|
||||||
|
return Ok(release_path);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn load_module(instance: &mut Instance, name: &str, path: Option<PathBuf>) -> MizeResult<()> {
|
||||||
|
|
||||||
let module_dir_str = instance.get("0/config/module_dir")?.value_string()?;
|
let module_dir_str = instance.get("0/config/module_dir")?.value_string()?;
|
||||||
let module_dir = Path::new(&module_dir_str);
|
let module_dir = Path::new(&module_dir_str);
|
||||||
|
|
||||||
let release_path = module_dir.join("modules").join(name).join("target").join("release").join(format!("libmize_module_{}.so", name));
|
let module_path = get_correct_module_path(module_dir, name)?;
|
||||||
let debug_path = module_dir.join("modules").join(name).join("target").join("debug").join(format!("libmize_module_{}.so", name));
|
|
||||||
|
|
||||||
let module_path = match seconds_since_modification(&release_path) > seconds_since_modification(&debug_path) {
|
|
||||||
true => debug_path,
|
|
||||||
false => release_path,
|
|
||||||
};
|
|
||||||
|
|
||||||
let lib = unsafe { libloading::Library::new(module_path)? };
|
let lib = unsafe { libloading::Library::new(module_path)? };
|
||||||
|
|
||||||
@@ -135,6 +147,7 @@ pub fn load_module(instance: &mut Instance, name: &str) -> MizeResult<()> {
|
|||||||
let mut module: Box<dyn Module + Send + Sync> = Box::new(EmptyModule {});
|
let mut module: Box<dyn Module + Send + Sync> = Box::new(EmptyModule {});
|
||||||
|
|
||||||
unsafe { func(&mut module) };
|
unsafe { func(&mut module) };
|
||||||
|
println!("hiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii load module");
|
||||||
|
|
||||||
|
|
||||||
let mut modules_inner = instance.modules.lock()?;
|
let mut modules_inner = instance.modules.lock()?;
|
||||||
|
|||||||
22
webfiles.nix
Normal file
22
webfiles.nix
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{ stdenv
|
||||||
|
, pkgs
|
||||||
|
, ... }:
|
||||||
|
let
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "mize-webfiles";
|
||||||
|
dontUnpack = true;
|
||||||
|
|
||||||
|
# so that /bin/sh does not get patched to a nix store path in victorinix-s
|
||||||
|
dontPatchShebangs = true;
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
mkdir -p $out
|
||||||
|
'';
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user