94 full_version->AddComponentVersion(
"Storage",
98 full_version->AddComponentVersion(
"Protocol",
122 arg_desc->SetUsageContext(
GetArguments().GetProgramBasename(),
123 "Network job queue server");
128 "File to save NetSchedule process PID",
130 arg_desc->AddFlag(
kReinitArgName,
"Recreate the storage directory.");
132 "Turn off daemonization of NetSchedule at the start.");
143 .
Print(
"_type",
"startup")
144 .
Print(
"info",
"versions")
159 .
Print(
"_type",
"startup")
160 .
Print(
"info",
"configuration")
167 vector<string> config_warnings;
168 bool admin_decrypt_error(
false);
183 server->SetCustomThreadSuffix(
"_h");
184 server->SetNSParameters(params,
false);
185 server->SetAnybodyCanReconfigure(admin_decrypt_error);
189 server->StartListening();
200 .
Print(
"_type",
"startup")
201 .
Print(
"info",
"entering UNIX daemon mode");
214 "Error during daemonization.");
218 .
Print(
"_type",
"startup")
219 .
Print(
"info",
"operating in non-daemon mode");
224 CNSPreciseTime min_run_timeout = qdb->Configure(reg, unused_diff);
230 .
Print(
"_type",
"startup")
231 .
Print(
"info",
"check running jobs expiration")
237 if (!config_warnings.empty()) {
239 for (vector<string>::const_iterator k = config_warnings.begin();
240 k != config_warnings.end(); ++k) {
250 vector<string> config_checksum_warnings;
253 if (config_checksum_warnings.empty()) {
254 server->SetRAMConfigFileChecksum(config_checksum);
255 server->SetDiskConfigFileChecksum(config_checksum);
257 for (vector<string>::const_iterator
258 k = config_checksum_warnings.begin();
259 k != config_checksum_warnings.end(); ++k)
263 qdb->RunExecutionWatcherThread(min_run_timeout);
264 qdb->RunPurgeThread();
265 qdb->RunNotifThread();
266 qdb->RunServiceThread();
268 server->SetQueueDB(qdb.release());
269 server->ReadServicesConfig(reg);
289 const string & section,
298 for (list<string>::const_iterator k =
entries.begin();
315 if (pid_file ==
"-") {
316 string msg =
"pid file cannot be standard output and only "
317 "file name is accepted";
324 if (access(pid_file.c_str(), F_OK) == 0) {
326 if (access(pid_file.c_str(), W_OK) != 0) {
327 string msg =
"pid file is not writable";
335 FILE *
f = fopen(pid_file.c_str(),
"w");
337 string msg =
"error opening pid file for writing";
348 int main(
int argc,
const char* argv[])
static CJsonNode NewObjectNode()
Create a new JSON object node.
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
CNetScheduleConnectionFactory::
STimeout m_ServerAcceptTimeout
map< string, string > m_OrigLogSection
int Run(void)
Run the application.
void x_SaveSection(const CNcbiRegistry ®, const string §ion, map< string, string > &storage)
void Init(void)
Initialize the application.
void x_WritePid(CNetScheduleServer *server) const
map< string, string > m_OrigDiagSection
NetSchedule internal exception.
NetScheduler threaded server.
static CNetScheduleServer * GetInstance(void)
void RegisterAlert(EAlertType alert_type, const string &message)
void SetShutdownFlag(int signum=0, bool db_was_drained=false)
virtual bool ShutdownRequested(void)
Runs synchronously between iterations.
The NCBI C++ standard methods for dealing with std::string.
void SetFullVersion(CRef< CVersionAPI > version)
Set version data for the program.
const CNcbiRegistry & GetConfig(void) const
Get the application's cached configuration parameters (read-only).
virtual const CArgs & GetArgs(void) const
Get parsed command line arguments.
int AppMain(int argc, const char *const *argv, const char *const *envp=0, EAppDiagStream diag=eDS_Default, const char *conf=NcbiEmptyCStr, const string &name=NcbiEmptyString)
Main function (entry point) for the NCBI application.
virtual void SetupArgDescriptions(CArgDescriptions *arg_desc)
Setup the command line argument descriptions.
const string & GetConfigPath(void) const
Get the full path to the configuration file (if any) we ended up using.
const CNcbiArguments & GetArguments(void) const
Get the application's cached unprocessed command-line arguments.
void SetVersion(const CVersionInfo &version)
Set the version number for the program.
@ fNoUsage
Do not print USAGE on argument error.
@ fDupErrToCerr
Print arg error to both log and cerr.
@ eOutputFile
Name of file (must be writable)
CDiagContext_Extra & Print(const string &name, const string &value)
The method does not print the argument, but adds it to the string.
CDiagContext & GetDiagContext(void)
Get diag context instance.
CDiagContext_Extra Extra(void) const
Create a temporary CDiagContext_Extra object.
static CRequestContext & GetRequestContext(void)
Shortcut to CDiagContextThreadData::GetThreadData().GetRequestContext()
static TPID GetPID(void)
Get cached PID (read real PID if not cached yet).
void SetAutoIncRequestIDOnPost(bool enable)
Auto-increment request ID with every posted message.
static void SetAllowedSessionIDFormat(ESessionIDFormat fmt)
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
static void SetDefaultAutoIncRequestIDOnPost(bool enable)
Set default auto-increment flag used for each default request context.
static void SetOldPostFormat(bool value)
Set old/new format flag.
void g_Diag_Use_RWLock(bool enable=true)
Use RW-lock for synchronization rather than mutex.
@ eSID_Other
Any other format.
@ eDS_ToStdlog
Try standard log file (app.name + ".log") in /log/ and current directory, use stderr if both fail.
void Critical(CExceptionArgs_Base &args)
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
void Warning(CExceptionArgs_Base &args)
static TPid Daemonize(const char *logfile=0, TDaemonFlags flags=0)
Go daemon.
@ fDF_KeepCWD
Don't change CWD to "/".
@ fDF_KeepStdout
Keep stdout open as "/dev/null" (WO)
@ fDF_KeepStdin
Keep stdin open as "/dev/null" (RO)
virtual bool HasEntry(const string §ion, const string &name=kEmptyStr, TFlags flags=0) const
virtual void EnumerateEntries(const string §ion, list< string > *entries, TFlags flags=fAllLayers) const
Enumerate parameter names for a specified section.
virtual string GetString(const string §ion, const string &name, const string &default_value, TFlags flags=0) const
Get the parameter string value.
bool Write(CNcbiOstream &os, TFlags flags=0) const
Write the registry content to output stream.
EIO_Status SOCK_InitializeAPI(void)
Initialize all internal/system data & resources to be used by the SOCK API.
ESOCK_IOWaitSysAPI SOCK_SetIOWaitSysAPI(ESOCK_IOWaitSysAPI api)
This is a helper call that can improve I/O performance (ignored for MSVC).
@ eSOCK_IOWaitSysAPIPoll
always use poll()
const char *const kEmptyCStr
Empty "C" string (points to a '\0').
const STimeout * accept_timeout
Maximum t between exit checks.
unsigned int usec
microseconds (modulo 1,000,000)
Compressed bitset (entry point to bm.h)
Parameters initialization model.
#define NCBI_PACKAGE_VERSION_PATCH
#define NCBI_PACKAGE_VERSION_MINOR
#define NCBI_PACKAGE_VERSION_MAJOR
Defines process management classes.
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
Defines command line argument related classes.
Defines NCBI C++ diagnostic APIs, classes, and macros.
Defines unified interface to application:
Miscellaneous common-use basic types and functionality.
Multi-threading – mutexes; rw-locks; semaphore.
Process information in the NCBI Registry, including working with configuration files.
#define NETSCHEDULED_VERSION
#define NETSCHEDULED_PROTOCOL_VERSION_MINOR
#define NETSCHEDULED_STORAGE_VERSION_MAJOR
#define NETSCHEDULED_STORAGE_VERSION_PATCH
#define NETSCHEDULED_STORAGE_VERSION
#define NETSCHEDULED_PROTOCOL_VERSION_PATCH
#define NETSCHEDULED_PROTOCOL_VERSION_MAJOR
#define NETSCHEDULED_PROTOCOL_VERSION
#define NETSCHEDULED_BUILD_DATE
#define NETSCHEDULED_STORAGE_VERSION_MINOR
static const string kReinitArgName
static const string kNodaemonArgName
int main(int argc, const char *argv[])
void Threaded_Server_SignalHandler(int signum)
static const string kPidFileArgName
double f(double x_, const double &y_)
string NS_FormatPreciseTimeAsSec(const CNSPreciseTime &t)
void NS_ValidateConfigFile(const IRegistry ®, vector< string > &warnings, bool throw_port_exception, bool &decrypting_error)
string NS_GetConfigFileChecksum(const string &file_name, vector< string > &warnings)
Framework to create multithreaded network servers with thread-per-request scheduling.
void Read(const IRegistry ®)
static wxAcceleratorEntry entries[3]