58 #include "maintagent.h" 61 char BuildVersion[]=
"maintagent build version: " VERSION_S
" r(" COMMIT_HASH_S
").\n";
69 int main(
int argc,
char **argv)
74 char agentRev[myBUFSIZ];
75 char *agentDesc =
"Maintenance Agent";
86 snprintf(agentRev,
sizeof(agentRev),
"%s.%s", VERSION, COMMIT_HASH);
90 int validateFoldersExe = 0;
91 int verifyFilePermsExe = 0;
92 int removeUploadsExe = 0;
93 int normalizeUploadPrioritiesExe = 0;
94 int removeTempsExe = 0;
95 int vacAnalyzeExe = 0;
96 int processExpiredExe = 0;
97 int removeOrphanedFilesExe = 0;
98 int reIndexAllTablesExe = 0;
99 int removeOrphanedRowsExe = 0;
100 int removeOrphanedLogs = 0;
103 while ((cmdopt = getopt(argc, argv,
"aAc:DEFghiILNpPRTUvVZ")) != -1)
108 if (validateFoldersExe == 0)
111 validateFoldersExe = 1;
113 if (verifyFilePermsExe == 0)
116 verifyFilePermsExe = 1;
118 if (removeUploadsExe == 0)
121 removeUploadsExe = 1;
123 if (normalizeUploadPrioritiesExe == 0)
126 normalizeUploadPrioritiesExe = 1;
128 if (removeTempsExe == 0)
133 if (vacAnalyzeExe == 0)
138 if (removeOrphanedLogs == 0)
141 removeOrphanedLogs = 1;
145 if (validateFoldersExe == 0)
148 validateFoldersExe = 1;
150 if (verifyFilePermsExe == 0)
153 verifyFilePermsExe = 1;
155 if (removeUploadsExe == 0)
158 removeUploadsExe = 1;
160 if (normalizeUploadPrioritiesExe == 0)
163 normalizeUploadPrioritiesExe = 1;
165 if (removeTempsExe == 0)
170 if (vacAnalyzeExe == 0)
175 if (processExpiredExe == 0)
178 processExpiredExe = 1;
180 if (removeOrphanedFilesExe == 0)
183 removeOrphanedFilesExe = 1;
185 if (reIndexAllTablesExe == 0)
188 reIndexAllTablesExe = 1;
190 if (removeOrphanedRowsExe == 0)
193 removeOrphanedRowsExe = 1;
195 if (removeOrphanedLogs == 0)
198 removeOrphanedLogs = 1;
202 if (vacAnalyzeExe == 0)
209 if (validateFoldersExe == 0)
212 validateFoldersExe = 1;
222 if (normalizeUploadPrioritiesExe == 0)
225 normalizeUploadPrioritiesExe = 1;
232 if (verifyFilePermsExe == 0)
235 verifyFilePermsExe = 1;
239 if (removeUploadsExe == 0)
242 removeUploadsExe = 1;
246 if (removeTempsExe == 0)
253 if (processExpiredExe == 0)
256 processExpiredExe = 1;
260 if (removeOrphanedFilesExe == 0)
263 removeOrphanedFilesExe = 1;
267 if (reIndexAllTablesExe == 0)
270 reIndexAllTablesExe = 1;
274 if (removeOrphanedRowsExe == 0)
277 removeOrphanedRowsExe = 1;
281 if (removeOrphanedLogs == 0)
284 removeOrphanedLogs = 1;
FUNCTION void removeOrphanedFiles()
Remove orphaned files from the repository (slow) Loop through each file in the repository and make su...
FUNCTION void removeTemps()
Remove orphaned temp tables from deprecated pkgmettagetta and old delagent.
FUNCTION void deleteOrphanGold()
Delete orphaned gold files from the repository Loop through each gold file in the repository and make...
FUNCTION void reIndexAllTables()
reindex of all indexes in fossology database
PGconn * pgConn
Database connection.
void fo_scheduler_connect(int *argc, char **argv, PGconn **db_conn)
Establish a connection between an agent and the scheduler.
FUNCTION void vacAnalyze()
Do database vacuum and analyze.
FUNCTION void removeOrphanedRows()
remove orphaned rows from fossology database
FUNCTION void verifyFilePerms(int fix)
Verify and optionally fix file permissions.
FUNCTION void normalizeUploadPriorities()
Normalize priority of Uploads.
int agent_verbose
Common verbose flags for the agents, this is used so that the scheduler can change the verbose level ...
fo_dbManager * fo_dbManager_new(PGconn *dbConnection)
Create and initialize new fo_dbManager object.
int main(int argc, char **argv)
Main entry point for the agent.
FUNCTION void processExpired()
Process expired uploads (slow)
FUNCTION void validateFolders()
Validate folder and foldercontents tables.
fo_dbManager * dbManager
fo_dbManager object
FUNCTION void removeOrphanedLogFiles()
FUNCTION int fo_GetAgentKey(PGconn *pgConn, const char *agent_name, long Upload_pk, const char *rev, const char *agent_desc)
Get the latest enabled agent key (agent_pk) from the database.
FUNCTION void usage(char *name)
FUNCTION void removeUploads()
Remove Uploads with no pfiles.
void exitNow(int exitVal)
Exit function. This does all cleanup and should be used instead of calling exit() or main() return...
char * fo_sysconfig(const char *sectionname, const char *variablename)
gets a system configuration variable from the configuration data.