Skip to content

Commit

Permalink
squash w/ startup/shutdown. [?] Remove unused function for executing …
Browse files Browse the repository at this point in the history
…external binaries and scripts. TODO: Need to pull code from original commit to remove PP conditions.
  • Loading branch information
korydraughn committed Nov 9, 2024
1 parent e628887 commit eb90ae4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 92 deletions.
9 changes: 0 additions & 9 deletions server/core/include/irods/miscServerFunct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,6 @@ irods::error readStartupPack(

irods::error setRECacheSaltFromEnv();

#if 0
irods::error get_script_output_single_line(
const std::string& script_language,
const std::string& script_name,
const std::vector<std::string>& args,
std::string& output );
#endif

irods::error add_global_re_params_to_kvp_for_dynpep(
keyValPair_t& _kvp );

Expand All @@ -159,5 +151,4 @@ irods::error list_rule_plugin_instances( std::vector< std::string >& );

#endif // __cplusplus


#endif /* MISC_SERVER_FUNCT_H */
83 changes: 0 additions & 83 deletions server/core/src/miscServerFunct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@
#include <boost/thread/scoped_thread.hpp>
#include <boost/lexical_cast.hpp>

#if 0
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wc++11-narrowing"
#include <boost/process.hpp>
#pragma GCC diagnostic pop
#endif

#include <fmt/format.h>

#include <sys/wait.h>
Expand Down Expand Up @@ -2992,82 +2985,6 @@ irods::error setRECacheSaltFromEnv()
return SUCCESS();
} // setRECacheSaltFromEnv

#if 0
irods::error get_script_output_single_line(
const std::string& script_language,
const std::string& script_name,
const std::vector<std::string>& args,
std::string& output ) {
namespace bp = boost::process;

try {
auto resolved_program = bp::search_path(script_language);
if (resolved_program.empty()) {
return ERROR(RESOLUTION_ERROR, fmt::format("Could not resolve {} to an executable", script_language));
}

// TODO Consider removing entirely. Currently, only the following things invoke this function:
// - server/api/src/rsServerReport.cpp:257: ret = get_script_output_single_line( "python3", "system_identification.py", args, os_distribution_name );
// - server/api/src/rsServerReport.cpp:268: ret = get_script_output_single_line( "python3", "system_identification.py", args, os_distribution_version );
//
// Have to support zone reports.
// The use of system_identification.py can be replaced with parsing of /etc/os-release
// and/or the POSIX uname() function. uname() will not return the same information, but
// maybe that's okay? Parsing /etc/os-release would give us more detailed OS information.
//
// The control plane is going away, so there's no need for pid_age.py to exist.
auto script_path = fmt::format("{}/scripts/{}", irods::get_irods_home_directory().c_str(), script_name);
if (!std::filesystem::exists(script_path)) {
return ERROR(RESOLUTION_ERROR, fmt::format("Script file not found! {}", script_path));
}

auto script_path_and_args = args;
script_path_and_args.insert(script_path_and_args.begin(), script_path);

bp::ipstream program_output;
bp::ipstream program_stderr;
bp::child c(resolved_program, script_path_and_args, bp::std_out > program_output, bp::std_err > program_stderr);
output.clear();
c.wait();
const auto ec = c.exit_code();

std::string stderr_output;
if (ec != 0 || (program_stderr && std::getline(program_stderr, stderr_output) && !stderr_output.empty())) {
irods::experimental::log::server::error(
"Received stderr output [{}] from script process [{} {}] which exited with code {}",
stderr_output,
script_language,
fmt::join(script_path_and_args, " "),
ec);
}

if (!program_output) {
return ERROR(SYS_PIPE_ERROR,
fmt::format("stdout was unable to be opened, process exited with code {}.", ec));
}

if (!std::getline(program_output, output)) {
return ERROR(SYS_PIPE_ERROR,
fmt::format("Unable to read line from child process, exited with code {}.", ec));
}

return SUCCESS();
}
catch (const bp::process_error& e) {
// In this case, the server is most likely unable to find a suitable
// executable to run with a given name
irods::experimental::log::server::error("Error starting process, {}", e.what());
return ERROR(SYS_LIBRARY_ERROR, e.what());
}
catch (const irods::exception& e) {
return ERROR(e.code(), e.what());
}
catch (const std::exception& e) {
return ERROR(SYS_INTERNAL_ERR, e.what());
}
} // get_script_output_single_line
#endif

irods::error add_global_re_params_to_kvp_for_dynpep(
keyValPair_t& _kvp ) {

Expand Down

0 comments on commit eb90ae4

Please sign in to comment.