<commit_before>/*
 * File:  stop_server.cpp
 * Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
 */

#include "sedna.h"

#include "base.h"
#include "d_printf.h"
#include "argtable.h"
#include "version.h"
#include "pping.h"
#include "ipc_ops.h"
#include "uprocess.h"

using namespace std;


const size_t narg = 3;
int ss_help;
int ss_version;

arg_rec ss_argtable[] =
{
{"--help",            NULL,       arg_lit,   &ss_help,                 "0",    "\t\t   display this help and exit"},
{"-help",             NULL,       arg_lit,   &ss_help,                 "0",    "\t\t\t   display this help and exit"},
{"-version",          NULL,       arg_lit,   &ss_version,              "0",    "\t\t   display product version and exit"}
};


void print_ss_usage()
{
   throw USER_SOFT_EXCEPTION((string("Usage: se_stop [options]\n\n") +
                              string("options:\n") + string(arg_glossary(ss_argtable, narg, "  ")) + string("\n")).c_str());
}


int main(int argc, char** argv)
{
    USOCKET sock;
    UShMem gov_mem_dsc;
    void* gov_shm_pointer = NULL;
    UPID gov_pid;
    int port_number;
    UPHANDLE proc_handle;
    int res;
    program_name_argv_0 = argv[0];


    pping_client ppc(5151);


    try {

        SednaUserException e = USER_EXCEPTION(SE4400);
        if (uSocketInit() == U_SOCKET_ERROR) throw USER_EXCEPTION (SE3001);


        int arg_scan_ret_val = 0; // 1 - parsed successful, 0 - there was errors
        char errmsg[1000];
        arg_scan_ret_val = arg_scanargv(argc, argv, ss_argtable, narg, NULL, errmsg, NULL);
        if (ss_help == 1 ) print_ss_usage();
        if (ss_version == 1) { print_version_and_copyright("Sedna Stop Server Utility"); throw USER_SOFT_EXCEPTION("");}

        if (arg_scan_ret_val == 0)
           throw USER_EXCEPTION2(SE4601, errmsg);


        set_global_names();

#ifdef REQUIRE_ROOT
        if (!uIsAdmin()) throw USER_EXCEPTION(SE3064);
#endif
        ppc.startup(e);
        ppc.shutdown();

        event_logger_init(EL_STOP, NULL, SE_EVENT_LOG_SHARED_MEMORY_NAME, SE_EVENT_LOG_SEMAPHORES_NAME);
        elog(EL_LOG, ("Request for GOVERNOR shutdown issued"));
        event_logger_release();

        gov_shm_pointer = open_gov_shm(&gov_mem_dsc);
<commit_msg>move-str-in-log<commit_after>/*
 * File:  stop_server.cpp
 * Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
 */

#include "sedna.h"

#include "base.h"
#include "d_printf.h"
#include "argtable.h"
#include "version.h"
#include "pping.h"
#include "ipc_ops.h"
#include "uprocess.h"

using namespace std;


const size_t narg = 3;
int ss_help;
int ss_version;

arg_rec ss_argtable[] =
{
{"--help",            NULL,       arg_lit,   &ss_help,                 "0",    "\t\t   display this help and exit"},
{"-help",             NULL,       arg_lit,   &ss_help,                 "0",    "\t\t\t   display this help and exit"},
{"-version",          NULL,       arg_lit,   &ss_version,              "0",    "\t\t   display product version and exit"}
};


void print_ss_usage()
{
   throw USER_SOFT_EXCEPTION((string("Usage: se_stop [options]\n\n") +
                              string("options:\n") + string(arg_glossary(ss_argtable, narg, "  ")) + string("\n")).c_str());
}


int main(int argc, char** argv)
{
    USOCKET sock;
    UShMem gov_mem_dsc;
    void* gov_shm_pointer = NULL;
    UPID gov_pid;
    int port_number;
    UPHANDLE proc_handle;
    int res;
    program_name_argv_0 = argv[0];


    pping_client ppc(5151);


    try {

        SednaUserException e = USER_EXCEPTION(SE4400);
        if (uSocketInit() == U_SOCKET_ERROR) throw USER_EXCEPTION (SE3001);


        int arg_scan_ret_val = 0; // 1 - parsed successful, 0 - there was errors
        char errmsg[1000];
        arg_scan_ret_val = arg_scanargv(argc, argv, ss_argtable, narg, NULL, errmsg, NULL);
        if (ss_help == 1 ) print_ss_usage();
        if (ss_version == 1) { print_version_and_copyright("Sedna Stop Server Utility"); throw USER_SOFT_EXCEPTION("");}

        if (arg_scan_ret_val == 0)
           throw USER_EXCEPTION2(SE4601, errmsg);


        set_global_names();

#ifdef REQUIRE_ROOT
        if (!uIsAdmin()) throw USER_EXCEPTION(SE3064);
#endif
        ppc.startup(e);

        event_logger_init(EL_STOP, NULL, SE_EVENT_LOG_SHARED_MEMORY_NAME, SE_EVENT_LOG_SEMAPHORES_NAME);
        elog(EL_LOG, ("Request for GOVERNOR shutdown issued"));
        event_logger_release();

        ppc.shutdown();

        gov_shm_pointer = open_gov_shm(&gov_mem_dsc);

{'fraction_non_alphanumeric': 0.12551844575420215, 'fraction_numerical': 0.017900021829294913, 'mean_word_length': 2.7588187038556193, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3798040', 'n_tokens_mistral': 1718, 'n_tokens_neox': 1616, 'n_words': 374}