mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-08-19 03:57:21 +00:00
allow setting cgroup dir mode
This commit is contained in:
@@ -161,6 +161,10 @@ void uwsgi_init_default() {
|
||||
|
||||
uwsgi.empty = "";
|
||||
|
||||
#ifdef __linux__
|
||||
uwsgi.cgroup_dir_mode = "0700";
|
||||
#endif
|
||||
|
||||
uwsgi.wait_read_hook = uwsgi_simple_wait_read_hook;
|
||||
uwsgi.wait_write_hook = uwsgi_simple_wait_write_hook;
|
||||
|
||||
|
||||
+9
-3
@@ -206,14 +206,20 @@ void uwsgi_set_cgroup() {
|
||||
usl = uwsgi.cgroup;
|
||||
|
||||
while (usl) {
|
||||
if (mkdir(usl->value, 0700)) {
|
||||
uwsgi_log("using Linux cgroup %s\n", usl->value);
|
||||
int mode = strtol(uwsgi.cgroup_dir_mode, 0, 8);
|
||||
if (mkdir(usl->value, mode)) {
|
||||
if (errno != EEXIST) {
|
||||
uwsgi_error("mkdir()");
|
||||
exit(1);
|
||||
}
|
||||
if (chmod(usl->value, mode)) {
|
||||
uwsgi_error("chmod()");
|
||||
exit(1);
|
||||
}
|
||||
uwsgi_log("using Linux cgroup %s with mode %o\n", usl->value, mode);
|
||||
}
|
||||
else {
|
||||
uwsgi_log("created Linux cgroup %s\n", usl->value);
|
||||
uwsgi_log("created Linux cgroup %s with mode %o\n", usl->value, mode);
|
||||
}
|
||||
|
||||
cgroup_taskfile = uwsgi_concat2(usl->value, "/tasks");
|
||||
|
||||
@@ -593,6 +593,7 @@ static struct uwsgi_option uwsgi_base_options[] = {
|
||||
#ifdef __linux__
|
||||
{"cgroup", required_argument, 0, "put the processes in the specified cgroup", uwsgi_opt_add_string_list, &uwsgi.cgroup, 0},
|
||||
{"cgroup-opt", required_argument, 0, "set value in specified cgroup option", uwsgi_opt_add_string_list, &uwsgi.cgroup_opt, 0},
|
||||
{"cgroup-dir-mode", required_argument, 0, "set permission for cgroup directory (default is 700)", uwsgi_opt_set_str, &uwsgi.cgroup_dir_mode, 0},
|
||||
{"namespace", required_argument, 0, "run in a new namespace under the specified rootfs", uwsgi_opt_set_str, &uwsgi.ns, 0},
|
||||
{"namespace-keep-mount", required_argument, 0, "keep the specified mountpoint in your namespace", uwsgi_opt_add_string_list, &uwsgi.ns_keep_mount, 0},
|
||||
{"ns", required_argument, 0, "run in a new namespace under the specified rootfs", uwsgi_opt_set_str, &uwsgi.ns, 0},
|
||||
|
||||
Reference in New Issue
Block a user