MCPcopy Create free account
hub / github.com/ClusterLabs/pacemaker / main

Function main

pengine/main.c:112–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110/* *INDENT-ON* */
111
112int
113main(int argc, char **argv)
114{
115 int flag;
116 int index = 0;
117 int argerr = 0;
118
119 crm_log_init(NULL, LOG_INFO, TRUE, FALSE, argc, argv, FALSE);
120 crm_set_options(NULL, "[options]",
121 long_options, "Daemon for calculating the cluster's response to events");
122
123 mainloop_add_signal(SIGTERM, pengine_shutdown);
124
125 while (1) {
126 flag = crm_get_option(argc, argv, &index);
127 if (flag == -1)
128 break;
129
130 switch (flag) {
131 case 'V':
132 crm_bump_log_level(argc, argv);
133 break;
134 case 'h': /* Help message */
135 crm_help('?', EX_OK);
136 break;
137 default:
138 ++argerr;
139 break;
140 }
141 }
142
143 if (argc - optind == 1 && safe_str_eq("metadata", argv[optind])) {
144 pe_metadata();
145 return 0;
146 }
147
148 if (optind > argc) {
149 ++argerr;
150 }
151
152 if (argerr) {
153 crm_help('?', EX_USAGE);
154 }
155
156 if (crm_is_writable(PE_STATE_DIR, NULL, CRM_DAEMON_USER, CRM_DAEMON_GROUP, FALSE) == FALSE) {
157 crm_err("Bad permissions on " PE_STATE_DIR ". Terminating");
158 fprintf(stderr, "ERROR: Bad permissions on " PE_STATE_DIR ". See logs for details\n");
159 fflush(stderr);
160 return 100;
161 }
162
163 crm_debug("Init server comms");
164 ipcs = mainloop_add_ipc_server(CRM_SYSTEM_PENGINE, QB_IPC_SHM, &ipc_callbacks);
165 if (ipcs == NULL) {
166 crm_err("Failed to create IPC server: shutting down and inhibiting respawn");
167 crm_exit(100);
168 }
169

Callers

nothing calls this directly

Calls 10

crm_log_initFunction · 0.85
crm_set_optionsFunction · 0.85
mainloop_add_signalFunction · 0.85
crm_get_optionFunction · 0.85
crm_bump_log_levelFunction · 0.85
crm_helpFunction · 0.85
pe_metadataFunction · 0.85
crm_is_writableFunction · 0.85
mainloop_add_ipc_serverFunction · 0.85
crm_exitFunction · 0.85

Tested by

no test coverage detected