Skip to content

Commit

Permalink
mxqd: Set MXQ_HOSTID to bootid-hex(starttime)-pid
Browse files Browse the repository at this point in the history
  • Loading branch information
mariux committed Sep 24, 2015
1 parent 6057a12 commit 4f2859e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
21 changes: 20 additions & 1 deletion mxqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,13 @@ int server_init(struct mxq_server *server, int argc, char *argv[])
char *arg_initial_tmpdir;
char arg_daemonize = 0;
char arg_nolog = 0;
char *str_bootid;
int opt;
unsigned long threads_total = 1;
unsigned long memory_total = 2048;
unsigned long memory_max = 0;
int i;
struct proc_pid_stat pps = {0};

struct mx_getopt_ctl optctl;
struct mx_option opts[] = {
Expand Down Expand Up @@ -409,6 +411,20 @@ int server_init(struct mxq_server *server, int argc, char *argv[])
}
}

res = mx_read_first_line_from_file("/proc/sys/kernel/random/boot_id", &str_bootid);
assert(res == 36);
assert(str_bootid);

server->boot_id = str_bootid;

res = mx_proc_pid_stat(&pps, getpid());
assert(res == 0);

server->starttime = pps.starttime;
mx_proc_pid_stat_free(&pps);

mx_asprintf_forever(&server->host_id, "%s-%llx-%x", server->boot_id, server->starttime, getpid());

server->slots = threads_total;;
server->memory_total = memory_total;
server->memory_max_per_slot = memory_max;
Expand Down Expand Up @@ -807,7 +823,7 @@ static int init_child_process(struct mxq_group_list *group, struct mxq_job *j)
mx_setenvf_forever("MXQ_SLOTS", "%lu", group->slots_per_job);
mx_setenvf_forever("MXQ_MEMORY", "%lu", g->job_memory);
mx_setenvf_forever("MXQ_TIME", "%d", g->job_time);
mx_setenvf_forever("MXQ_HOSTID", "%s::%s", s->hostname, s->server_id);
mx_setenv_forever("MXQ_HOSTID", s->host_id);
mx_setenv_forever("MXQ_HOSTNAME", s->hostname);
mx_setenv_forever("MXQ_SERVERID", s->server_id);

Expand Down Expand Up @@ -1351,6 +1367,8 @@ void server_close(struct mxq_server *server)
unlink(server->pidfilename);

mx_funlock(server->flock);

mx_free_null(server->boot_id);
}

int killall(struct mxq_server *server, int sig, unsigned int pgrp)
Expand Down Expand Up @@ -1693,6 +1711,7 @@ int main(int argc, char *argv[])
mx_log_info(" by Marius Tolzmann <tolzmann@molgen.mpg.de> " MXQ_VERSIONDATE);
mx_log_info(" Max Planck Institute for Molecular Genetics - Berlin Dahlem");
mx_log_info("hostname=%s server_id=%s :: MXQ server started.", server.hostname, server.server_id);
mx_log_info(" host_id=%s", server.host_id);
mx_log_info("slots=%lu memory_total=%lu memory_avg_per_slot=%.0Lf memory_max_per_slot=%ld :: server initialized.",
server.slots, server.memory_total, server.memory_avg_per_slot, server.memory_max_per_slot);

Expand Down
3 changes: 3 additions & 0 deletions mxqd.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ struct mxq_server {

struct mx_mysql *mysql;

char *boot_id;
unsigned long long int starttime;
char *host_id;
char *hostname;
char *server_id;
char *lockfilename;
Expand Down

2 comments on commit 4f2859e

@donald
Copy link
Contributor

@donald donald commented on 4f2859e Oct 9, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the plan with host_id?
It is copied from server to job, but doesn't seem to make a functional difference in mxqd. The only usage currently is in the query in mxq_set_job_status_loaded_on_server but this shouldn't make a difference, because job_id alone is unique.
The user jobs get it via environment, but what are they supposed to do with it?

@mariux
Copy link
Contributor Author

@mariux mariux commented on 4f2859e Oct 9, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no real "plan", but improve existing host_id

this is a uniq id for the mxqd process "runnning server".

since pid+hostname+server_id alone is not unique (recycled pid or even reproducable startup of sevrer might end up with the same pid after every reboot.. ;))

hostname::server_id is not uniq at all.. so this infomation was useless...

this is not used to identify a job..

it might be used to identify reboots, restarts, and group jobs that all run under the control of the same mxqd process (for statistical reasons or whatever)

this implements #23

Please sign in to comment.