Skip to content

Commit

Permalink
draft: maybe fixes template_not_found
Browse files Browse the repository at this point in the history
  • Loading branch information
dcdgo committed Mar 9, 2021
1 parent 085cde8 commit 6a43cc0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
11 changes: 9 additions & 2 deletions C_part/src/nsvg/copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
#include <nanosvg.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

#include "../utility/logger.h"
#include "../utility/error.h";
#include "../utility/error.h"

const char* TEMPLATE_PATH = "template.svg";

Expand Down Expand Up @@ -32,12 +34,17 @@ char* gettemplate(int width, int height) {
size_t size;
char* data = NULL;
fp = fopen(TEMPLATE_PATH, "rb");

if(fp == NULL && chdir("./target/release/") == 0) { //couldnt find template here and alternative location DOES exist
fp = fopen(TEMPLATE_PATH, "rb");
}

if (!fp) {
if(fp == NULL) { //still null after trying fix
LOG_ERR("could not find svg template file.");
setError(TEMPLATE_FILE_NOT_FOUND);
return NULL;
};

fseek(fp, 0, SEEK_END);
size = ftell(fp);
fseek(fp, 0, SEEK_SET);
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ COPY ./ /home/sjsui/vectorizer/
# set environment variables
ENV conanpath /root/.conan/data/
ENV releasebuild true
ENV PATH $PATH:/home/sjsui/vectorizer/Rust_part/target/release/bot
ENV PATH $PATH:/home/sjsui/vectorizer/Rust_part/target/release

# initialize build tools
WORKDIR /home/sjsui/vectorizer/C_part/build/
Expand All @@ -34,4 +34,5 @@ WORKDIR /home/sjsui/vectorizer/Rust_part/
RUN cargo build -vv --release

#create entrypoint of container
CMD ["./target/release/trampoline"]
WORKDIR /home/sjsui/vectorizer/Rust_part/target/release/
CMD ["./trampoline"]
1 change: 0 additions & 1 deletion Rust_part/src/bot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ async fn vectorize(ctx: &Context, msg: &Message) -> CommandResult
}

println!("Sending {0} urls to vectoriser", embed_urls.len());
println!("Yo Mama {:?}", embed_urls);
vectorize_urls(&ctx, &msg, &embed_urls).await;

Ok(())
Expand Down
3 changes: 2 additions & 1 deletion Rust_part/src/trampoline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use tokio::time::sleep;
use error_show::error_string;
use std::sync::Arc;
use vecbot::bot::{END_MESSAGE, START_MESSAGE, ERR_MESSAGE};
use std::env;
struct TrampolineData {
pub vectorizer: Child,
pub vectorizer_finished: bool
Expand Down Expand Up @@ -139,7 +140,7 @@ async fn start_vectorizer_bot(data: &Arc<RwLock<TypeMap>>)

async fn initialize_child(data: &Arc<RwLock<TypeMap>>) {
println!("starting vectorizer...");
let created_process = Command::new("./target/release/bot").spawn().unwrap(); //if path is not absolute, path variable is searched
let created_process = Command::new("bot").spawn().unwrap(); //if path is not absolute, path variable is searched
initialize_data_insert(data, created_process).await;
}

Expand Down

0 comments on commit 6a43cc0

Please sign in to comment.