Commit fb2a84d4 authored by Robert Butora's avatar Robert Butora
Browse files

soda: removes Amqp & merge

parent 4f76dc9e
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -33,5 +33,4 @@ upload-war-deb:
	curl --header "PRIVATE-TOKEN: glpat-JhqpFhEGvxuVzHqxjwqx" --upload-file vlkb-soda-$(VERSION).war  https://ict.inaf.it/gitlab/api/v4/projects/1780/packages/generic/vlkb-soda/1.7/vlkb-soda-$(VERSION).war
	curl --header "PRIVATE-TOKEN: glpat-JhqpFhEGvxuVzHqxjwqx" --upload-file vlkb-$(VERSION).deb  https://ict.inaf.it/gitlab/api/v4/projects/1780/packages/generic/vlkb-soda/1.7/ubuntu22/vlkb-$(VERSION).deb
	curl --header "PRIVATE-TOKEN: glpat-JhqpFhEGvxuVzHqxjwqx" --upload-file vlkb-obscore-$(VERSION).deb  https://ict.inaf.it/gitlab/api/v4/projects/1780/packages/generic/vlkb-soda/1.7/ubuntu22/vlkb-obscore-$(VERSION).deb
	curl --header "PRIVATE-TOKEN: glpat-JhqpFhEGvxuVzHqxjwqx" --upload-file vlkbd-$(VERSION).deb  https://ict.inaf.it/gitlab/api/v4/projects/1780/packages/generic/vlkb-soda/1.7/ubuntu22/vlkbd-$(VERSION).deb
+0 −24
Original line number Diff line number Diff line

PREFIX ?= /usr/local

AMQP_QUEUE ?= vlkbdevel
INST_PATH ?= $(PREFIX)
VERSION ?= $(shell git describe)

@@ -13,14 +12,12 @@ all : build
.PHONY: build
build:
	make -C src/common VERSION=$(VERSION)
	make -C src/vlkbd VERSION=$(VERSION)
	make -C src/vlkb-obscore VERSION=$(VERSION)
	make -C src/vlkb VERSION=$(VERSION)

.PHONY: clean
clean:
	make -C src/common clean
	make -C src/vlkbd clean
	make -C src/vlkb-obscore clean
	make -C src/vlkb clean

@@ -31,15 +28,11 @@ install:
	mkdir -p $(INST_PATH)/bin
	install ./src/vlkb/bin/vlkb $(INST_PATH)/bin
	install ./src/vlkb-obscore/bin/vlkb-obscore $(INST_PATH)/bin
	install ./src/vlkbd/bin/vlkbd $(INST_PATH)/bin
	install vlkbd_exec.sh $(INST_PATH)/bin

.PHONY: uninstall
uninstall:
	rm -f $(INST_PATH)/bin/vlkb
	rm -f $(INST_PATH)/bin/vlkb-obscore
	rm -f $(INST_PATH)/bin/vlkbd
	rm -f $(INST_PATH)/bin/vlkbd_exec.sh



@@ -53,25 +46,8 @@ vlkb-devel: stop uninstall clean build install config start
.PHONY: config
config:
	mkdir -p $(INST_PATH)/etc/vlkb-obscore
	mkdir -p $(INST_PATH)/etc/vlkbd
	cp config/vlkb-obscore.datasets.conf $(INST_PATH)/etc/vlkb-obscore/datasets.conf
	cp config/vlkbd.datasets.conf $(INST_PATH)/etc/vlkbd/datasets.conf
	

.PHONY: start
start:
	vlkbd_exec.sh localhost $(AMQP_QUEUE) $(INST_PATH)/etc/vlkbd/datasets.conf

.PHONY: stop
stop:
	pkill -f 'vlkbd.* $(AMQP_QUEUE).*$(INST_PATH)/etc/vlkbd/datasets.conf'

.PHONY: status
status:
	ps ax | grep vlkbd

.PHONY: reload
reload: stop start


+0 −83
Original line number Diff line number Diff line
#================================================================================
EXEC_NAME = vlkbd
VERSION ?= $(shell git describe)
BUILD_ ?= $(shell LANG=us_US date; hostname)
#================================================================================
DEPS_DIR := ../common ../../ext/aria-csv ../../ext/nlohmann-json
DEPS_INC := $(foreach d, $(DEPS_DIR), $d/include)
DEPS_LIB := $(foreach d, $(DEPS_DIR), $d/lib)
#================================================================================
COMMON_DIR=../common
COMMON_LIB = $(COMMON_DIR)/lib/libvlkbcommon.a
#================================================================================
INC_DIR=src $(DEPS_INC) $(COMMON_DIR)/include  ../../ext \
	/usr/include/cfitsio \
	/usr/include/postgresql
LIB_DIR= $(DEPS_LIB) $(COMMON_DIR)/lib /usr/lib64/ast /usr/local/lib
#================================================================================
CC=g++
CXX_DEBUG_FLAGS=-g -DFDB_DEBUG
CXX_RELEASE_FLAGS=-O2
CXX_DEFAULT_FLAGS=-c -x c++ -std=c++11 -fPIC -Wall -Wextra -Wconversion -fno-common -DVERSIONSTR='"$(VERSION)"' -DBUILD='"$(BUILD_)"'
# FIXME: -last_pal missing in some builds (not realluy needed only for linker)
LDFLAGS = -Wall -lvlkbcommon -lpq -lpqxx -lcfitsio -lrabbitmq -last -last_grf_2.0 -last_grf_3.2 -last_grf_5.6 -last_grf3d -last_err -pthread -lstdc++ -lm
INC_PARM=$(foreach d, $(INC_DIR), -I$d)
LIB_PARM=$(foreach d, $(LIB_DIR), -L$d)
#================================================================================
SRC_DIR=src
OBJ_DIR=obj
BIN_DIR=bin
#================================================================================
EXECUTABLE	:= $(BIN_DIR)/$(EXEC_NAME)
CPP_FILES 	:= $(wildcard $(SRC_DIR)/*.cpp)
OBJ_FILES 	:= $(addprefix $(OBJ_DIR)/,$(notdir $(CPP_FILES:.cpp=.o)))
#================================================================================
NPROCS = $(shell grep -c 'processor' /proc/cpuinfo)
MAKEFLAGS += -j$(NPROCS)
#================================================================================

.PHONY: all
all : debug

.PHONY: release
release: CXXFLAGS+=$(CXX_RELEASE_FLAGS) $(CXX_DEFAULT_FLAGS)
release: $(EXECUTABLE)

.PHONY: debug
debug: CXXFLAGS+=$(CXX_DEBUG_FLAGS) $(CXX_DEFAULT_FLAGS)
debug: $(EXECUTABLE)

$(EXECUTABLE) : $(COMMON_LIB) makedir $(OBJ_FILES)
	$(CC) $(OBJ_FILES) $(LIB_PARM) $(LDFLAGS) -o $@

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
	        $(CC) $(CXXFLAGS) $(INC_PARM) -o $@ $<

.PHONY: $(COMMON_LIB)
$(COMMON_LIB) :
	   make -C $(COMMON_DIR)

.PHONY: makedir
makedir:
	-mkdir -p $(OBJ_DIR) $(BIN_DIR)


.PHONY: clean
clean :
	-rm -fr $(OBJ_DIR) $(BIN_DIR)



.PHONY: test
test :
	@tabs 20
	@echo -e "EXEC_NAME:\t"  $(EXEC_NAME)
	@echo -e "VERSION:\t"  $(VERSION)
	@echo -e "CPP_FILES:\t"  $(CPP_FILES)
	@echo -e "OBJ_FILES:\t"  $(OBJ_FILES)
	@echo -e "C_FILES:\t"  $(C_FILES)
	@echo -e "C_OBJ_FILES:\t"  $(C_OBJ_FILES)
	@echo -e "INC_PARM:\t"  $(INC_PARM)
	@echo -e "LIB_PARM:\t"  $(LIB_PARM)

+0 −76
Original line number Diff line number Diff line

#include "io.hpp"
#include "config.hpp"

#include <iostream>
#include <fstream>
#include <sstream>
#include <map>

/*/ C
#include <stdio.h>
#include <stdlib.h> // atoi needed
#include <string.h>
*/

using namespace std;

void config::read_config(const std::string & settings_path)
{
   std::ifstream settings_file(settings_path);
   std::string line;

   LOG_STREAM << "config::read_config()" << endl;

   if (settings_file.fail())
   {
      LOG_STREAM << "config file does not exist. Default options used." << endl;

      return;
   }


   while (std::getline(settings_file, line))
   {
      std::istringstream iss(line);
      std::string id, eq, val;

      if (std::getline(iss, id, '='))
      {
         if (std::getline(iss, val))
         {
            if (m_settings.find(id) != m_settings.end())
            {
               if (val.empty())
               {
                  LOG_STREAM << "config " << id.c_str()
                     << " is empty. Keeping default " << m_settings[id].c_str() << endl;
               }
               else
               {
                  m_settings[id] = val;
                  LOG_STREAM << "config " << id.c_str()
                     <<" read as " << m_settings[id].c_str() << endl;
               }
            }
            else
            {
               //Not present in map
               LOG_STREAM << "Setting "<< id.c_str() << " not defined, ignoring it" << endl;
               continue;
            }
         }
         else
         {
            // Comment line, skiping it
            continue;
         }
      }
      else
      {
         //Empty line, skipping it
         continue;
      }
   }
}
+0 −114
Original line number Diff line number Diff line

#ifndef CONFIG_HPP
#define CONFIG_HPP

#include <string>
#include <map>


class config
{
   public:

      void read_config(const std::string & settings_path);

      std::string getLogDir() const      {return m_settings.at(log_dir);}
      std::string getLogFileName() const {return m_settings.at(log_filename);}

//     std::string getAuthority() const          {return m_settings.at(ivoid_authority);}
//      std::string getResourceKey() const        {return m_settings.at(ivoid_resource_key);}
//      std::string getObsCorePublisher() const   {return std::string{"ivo://"} + getAuthority() + std::string{"/"} + getResourceKey();}
//      std::string getObsCoreAccessFormat() const {return m_settings.at(obscore_access_format);}
      
//      std::string getRemoteFitsDir() const {return m_settings.at(fits_url);}
      std::string getFitsDir() const       {return m_settings.at(fits_dir);}
      std::string getFitsCutDir() const    {return m_settings.at(fits_cutdir);}
/*
      std::string getDbms() const       {return m_settings.at(db_dbms);}
      std::string getDbHostName() const {return m_settings.at(db_host_name);}
      std::string getDbPort() const     {return m_settings.at(db_port);}
      std::string getDbSchema() const   {return m_settings.at(db_schema);}
      std::string getDbName() const     {return m_settings.at(db_name);}
      std::string getDbUserName() const {return m_settings.at(db_user_name);}
      std::string getDbPassword() const {return m_settings.at(db_password);}

      std::string getDbUri(bool with_password = false) const
      {return
	      m_settings.at(db_dbms)
		      + "://"
		      + m_settings.at(db_user_name)
		      + (with_password ? ":"+m_settings.at(db_password)  : "")
		      + "@"
		      + m_settings.at(db_host_name)
		      + ":"
		      + m_settings.at(db_port)
		      + "/"
		      + m_settings.at(db_name);
      }

      std::string getDbPostgresConnectString(bool with_password = false) const
      {return
	      "dbname = "  + m_settings.at(db_name)
		      + " port = " + m_settings.at(db_port)
		      + " host = " + m_settings.at(db_host_name)
		      + " user = " + m_settings.at(db_user_name)
		      + (with_password ? " password = " + m_settings.at(db_password)  : "")
		      + " options=\'-c search_path=" + m_settings.at(db_schema) + "\'";
      }
*/
   private:
      std::string value(std::string key) {return m_settings.at(key);}

      const std::string fits_dir{"fits_path_surveys"};
      const std::string fits_cutdir{"fits_path_cutouts"};

      const std::string log_dir{"log_dir"};
      const std::string log_filename{"log_filename"};

//      const std::string fits_url{"fits_url_surveys"};
/*      const std::string ivoid_authority{"ivoid_authority"};
      const std::string ivoid_resource_key{"ivoid_resource_key"};
      const std::string obscore_access_format{"obscore_access_format"};

      const std::string db_dbms{"db_dbms"};
      const std::string db_host_name{"db_host_name"};
      const std::string db_port{"db_port"};
      const std::string db_user_name{"db_user_name"};
      const std::string db_password{"db_password"};
      const std::string db_name{"db_name"};
      const std::string db_schema{"db_schema"};
*/
      //-------------------------------------------------
      // defaults
      //-------------------------------------------------

      const std::string empty_string;

      std::map<const std::string, std::string> m_settings 
      {
         {fits_dir, "/srv/surveys"},
         {fits_cutdir, "/srv/cutouts"},

         {log_dir, "/tmp"},
         {log_filename, "vlkbd.log"},
/*
            {ivoid_authority, 	empty_string},
            {ivoid_resource_key, 	empty_string},
            {obscore_access_format, 	"application/fits"},

            {fits_url, 	empty_string},

            {db_dbms, 	empty_string},
            {db_host_name,	empty_string},
            {db_port, 	empty_string},
            {db_user_name, 	empty_string},
            {db_password, 	empty_string},
            {db_name, 	empty_string},
            {db_schema, 	empty_string}
*/      
      };
};


#endif
Loading