What's the best way to have uwsgi create a '/run/uwsgi' folder on reboot?
Clash Royale CLAN TAG#URR8PPP
I have set up a Django project to run with uwsgi and nginx and it's all running as expected, except that when I reboot uwsgi will not launch correctly until the /run/ folder is recreated on the fs. /run is mapped to 'tmpfs' so it needs to be recreated at each boot.
I have a systemd service file that I created for uwsgi:
[Unit]
Description=uWSGI Module
After=syslog.target
[Service]
ExecStart=/usr/bin/uwsgi --ini /etc/uwsgi.ini
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=main
[Install]
WantedBy=multi-user.target
And the /etc/uwsgi.ini
file looks like this:
[uwsgi]
uid = uwsgi
gid = uwsgi
pidfile = /run/uwsgi/uwsgi.pid
stats = /run/uwsgi/stats.sock
socket = /run/uwsgi/uwsgi.sock
master = true
processes = 1
chdir = /path/to/our/django/app
module = icscada
max-requests = 100
daemonize = /var/log/uwsgi.log
What is the recommended way for the /run/uwsgi
folder to be recreated at each boot?
systemd uwsgi
|
show 1 more comment
I have set up a Django project to run with uwsgi and nginx and it's all running as expected, except that when I reboot uwsgi will not launch correctly until the /run/ folder is recreated on the fs. /run is mapped to 'tmpfs' so it needs to be recreated at each boot.
I have a systemd service file that I created for uwsgi:
[Unit]
Description=uWSGI Module
After=syslog.target
[Service]
ExecStart=/usr/bin/uwsgi --ini /etc/uwsgi.ini
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=main
[Install]
WantedBy=multi-user.target
And the /etc/uwsgi.ini
file looks like this:
[uwsgi]
uid = uwsgi
gid = uwsgi
pidfile = /run/uwsgi/uwsgi.pid
stats = /run/uwsgi/stats.sock
socket = /run/uwsgi/uwsgi.sock
master = true
processes = 1
chdir = /path/to/our/django/app
module = icscada
max-requests = 100
daemonize = /var/log/uwsgi.log
What is the recommended way for the /run/uwsgi
folder to be recreated at each boot?
systemd uwsgi
I am not aware ofuwsgi
but if the program runs fine as long as/run/uwsgi
folder is present, you can addmkdir /run/uwsgi
to your/etc/rc.local
file and every time when the system reboots, the folder would be created.
– Ramesh
Apr 17 '14 at 20:39
@Ramesh, that happens too late. The folder is created by /etc/rc.local, but systemd has already tried to init the module and failed.
– Octopus
Apr 17 '14 at 21:06
You probably need to add the run control script to/etc/init.d
. You can find more information regarding the same from here. docs.oracle.com/cd/E19683-01/806-4073/6jd67r96g/index.html
– Ramesh
Apr 17 '14 at 22:14
What is your distribution?/run
should be created fairly early on by the boot scripts. Do you have an older distribution that doesn't create/run
at all, or is your problem arranging to start uswgi late enough?
– Gilles
Apr 17 '14 at 23:55
1
@Gilles, /run is created. i want to also create /run/uwsgi/ at roughly the same time. or at least before systemd loads modules. this is on fedora 16 and later (i'd prefer a solution that is generally os agnostic)
– Octopus
Apr 18 '14 at 1:24
|
show 1 more comment
I have set up a Django project to run with uwsgi and nginx and it's all running as expected, except that when I reboot uwsgi will not launch correctly until the /run/ folder is recreated on the fs. /run is mapped to 'tmpfs' so it needs to be recreated at each boot.
I have a systemd service file that I created for uwsgi:
[Unit]
Description=uWSGI Module
After=syslog.target
[Service]
ExecStart=/usr/bin/uwsgi --ini /etc/uwsgi.ini
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=main
[Install]
WantedBy=multi-user.target
And the /etc/uwsgi.ini
file looks like this:
[uwsgi]
uid = uwsgi
gid = uwsgi
pidfile = /run/uwsgi/uwsgi.pid
stats = /run/uwsgi/stats.sock
socket = /run/uwsgi/uwsgi.sock
master = true
processes = 1
chdir = /path/to/our/django/app
module = icscada
max-requests = 100
daemonize = /var/log/uwsgi.log
What is the recommended way for the /run/uwsgi
folder to be recreated at each boot?
systemd uwsgi
I have set up a Django project to run with uwsgi and nginx and it's all running as expected, except that when I reboot uwsgi will not launch correctly until the /run/ folder is recreated on the fs. /run is mapped to 'tmpfs' so it needs to be recreated at each boot.
I have a systemd service file that I created for uwsgi:
[Unit]
Description=uWSGI Module
After=syslog.target
[Service]
ExecStart=/usr/bin/uwsgi --ini /etc/uwsgi.ini
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=main
[Install]
WantedBy=multi-user.target
And the /etc/uwsgi.ini
file looks like this:
[uwsgi]
uid = uwsgi
gid = uwsgi
pidfile = /run/uwsgi/uwsgi.pid
stats = /run/uwsgi/stats.sock
socket = /run/uwsgi/uwsgi.sock
master = true
processes = 1
chdir = /path/to/our/django/app
module = icscada
max-requests = 100
daemonize = /var/log/uwsgi.log
What is the recommended way for the /run/uwsgi
folder to be recreated at each boot?
systemd uwsgi
systemd uwsgi
edited Jun 21 '16 at 14:16
Valentin Bajrami
5,93111627
5,93111627
asked Apr 17 '14 at 20:30
OctopusOctopus
94251322
94251322
I am not aware ofuwsgi
but if the program runs fine as long as/run/uwsgi
folder is present, you can addmkdir /run/uwsgi
to your/etc/rc.local
file and every time when the system reboots, the folder would be created.
– Ramesh
Apr 17 '14 at 20:39
@Ramesh, that happens too late. The folder is created by /etc/rc.local, but systemd has already tried to init the module and failed.
– Octopus
Apr 17 '14 at 21:06
You probably need to add the run control script to/etc/init.d
. You can find more information regarding the same from here. docs.oracle.com/cd/E19683-01/806-4073/6jd67r96g/index.html
– Ramesh
Apr 17 '14 at 22:14
What is your distribution?/run
should be created fairly early on by the boot scripts. Do you have an older distribution that doesn't create/run
at all, or is your problem arranging to start uswgi late enough?
– Gilles
Apr 17 '14 at 23:55
1
@Gilles, /run is created. i want to also create /run/uwsgi/ at roughly the same time. or at least before systemd loads modules. this is on fedora 16 and later (i'd prefer a solution that is generally os agnostic)
– Octopus
Apr 18 '14 at 1:24
|
show 1 more comment
I am not aware ofuwsgi
but if the program runs fine as long as/run/uwsgi
folder is present, you can addmkdir /run/uwsgi
to your/etc/rc.local
file and every time when the system reboots, the folder would be created.
– Ramesh
Apr 17 '14 at 20:39
@Ramesh, that happens too late. The folder is created by /etc/rc.local, but systemd has already tried to init the module and failed.
– Octopus
Apr 17 '14 at 21:06
You probably need to add the run control script to/etc/init.d
. You can find more information regarding the same from here. docs.oracle.com/cd/E19683-01/806-4073/6jd67r96g/index.html
– Ramesh
Apr 17 '14 at 22:14
What is your distribution?/run
should be created fairly early on by the boot scripts. Do you have an older distribution that doesn't create/run
at all, or is your problem arranging to start uswgi late enough?
– Gilles
Apr 17 '14 at 23:55
1
@Gilles, /run is created. i want to also create /run/uwsgi/ at roughly the same time. or at least before systemd loads modules. this is on fedora 16 and later (i'd prefer a solution that is generally os agnostic)
– Octopus
Apr 18 '14 at 1:24
I am not aware of
uwsgi
but if the program runs fine as long as /run/uwsgi
folder is present, you can add mkdir /run/uwsgi
to your /etc/rc.local
file and every time when the system reboots, the folder would be created.– Ramesh
Apr 17 '14 at 20:39
I am not aware of
uwsgi
but if the program runs fine as long as /run/uwsgi
folder is present, you can add mkdir /run/uwsgi
to your /etc/rc.local
file and every time when the system reboots, the folder would be created.– Ramesh
Apr 17 '14 at 20:39
@Ramesh, that happens too late. The folder is created by /etc/rc.local, but systemd has already tried to init the module and failed.
– Octopus
Apr 17 '14 at 21:06
@Ramesh, that happens too late. The folder is created by /etc/rc.local, but systemd has already tried to init the module and failed.
– Octopus
Apr 17 '14 at 21:06
You probably need to add the run control script to
/etc/init.d
. You can find more information regarding the same from here. docs.oracle.com/cd/E19683-01/806-4073/6jd67r96g/index.html– Ramesh
Apr 17 '14 at 22:14
You probably need to add the run control script to
/etc/init.d
. You can find more information regarding the same from here. docs.oracle.com/cd/E19683-01/806-4073/6jd67r96g/index.html– Ramesh
Apr 17 '14 at 22:14
What is your distribution?
/run
should be created fairly early on by the boot scripts. Do you have an older distribution that doesn't create /run
at all, or is your problem arranging to start uswgi late enough?– Gilles
Apr 17 '14 at 23:55
What is your distribution?
/run
should be created fairly early on by the boot scripts. Do you have an older distribution that doesn't create /run
at all, or is your problem arranging to start uswgi late enough?– Gilles
Apr 17 '14 at 23:55
1
1
@Gilles, /run is created. i want to also create /run/uwsgi/ at roughly the same time. or at least before systemd loads modules. this is on fedora 16 and later (i'd prefer a solution that is generally os agnostic)
– Octopus
Apr 18 '14 at 1:24
@Gilles, /run is created. i want to also create /run/uwsgi/ at roughly the same time. or at least before systemd loads modules. this is on fedora 16 and later (i'd prefer a solution that is generally os agnostic)
– Octopus
Apr 18 '14 at 1:24
|
show 1 more comment
5 Answers
5
active
oldest
votes
From tmpfiles.d(5):
System daemons frequently require private runtime directories below /run to place communication sockets and similar in. For these, consider declaring them in their unit files using RuntimeDirectory= (see systemd.exec(5) for details), if this is feasible.
And from systemd.exec(5):
RuntimeDirectory=, RuntimeDirectoryMode=
Takes a list of directory names. If set, one or more directories by the specified names will be created below /run (for system services) or below $XDG_RUNTIME_DIR (for user services) when the unit is started, and removed when the unit is stopped. The directories will have the access mode specified in RuntimeDirectoryMode=, and will be owned by the user and group specified in User= and Group=. Use this to manage one or more runtime directories of the unit and bind their lifetime to the daemon runtime.
In other words, while using tmpfiles.d for this "works", the officially recommended way is to add
RuntimeDirectory=uwsgi
to the [Service]
section of your unit file.
This has the advantage that it is briefer, guarantees that it's created with the correct user/group ownership, and cleans up the directory when the daemon is stopped.
Note that these options were added in a relatively recent version of systemd and may not be in the version on your server. Check your local man page for systemd.exec. if it's not there, you can't use it.
– Eddie
Jun 22 '15 at 22:58
This is the answer!
– ATOzTOA
Oct 7 '16 at 0:15
Yep. But watch it: those systemd parameters are f'king case-sensitive. And don't forget to dodaemon-reload
– Otheus
Nov 10 '16 at 20:42
add a comment |
You need to create a configuration file under /etc/tmpfiles.d/
defining that this directory should be created by systemd during boot/startup.
Example
$ more /etc/tmpfiles.d/uwsgi.conf
D /run/uwsgi 0770 uwsgi uwsgi -
Set it with whatever ownership/permissions you deem are appropriate for your situation.
NOTE: If you use the setup I provided above then you'll likely want to add the group uwsgi
to Nginx's user nginx
:
$ sudo usermod -a nginx -G uwsgi
References
- Adding the Emperor to systemd
- The uWSGI Emperor – multi-app deployment
add a comment |
The way I eventually solved this problem was to use the latest distributions. Fedora 20 and yum install uwsgi
built an environment where all of these details were handled automatically for me, while I was previously trying to fudge this onto a Fedora17 system where it wasn't available in the yum repositories.
The way Fedora 20 solves this is by having this in its uwsgi service unit:
ExecStartPre=/bin/mkdir -p /run/uwsgi
ExecStartPre=/bin/chown uwsgi:uwsgi /run/uwsgi
1
The way Fedora 20 solves this is by having this in its uwsgi service unit:ExecStartPre=/bin/mkdir -p /run/uwsgi
ExecStartPre=/bin/chown uwsgi:uwsgi /run/uwsgi
– jsbillings
May 22 '14 at 19:28
1
Yes, definitely worth mentioning that in the answer, thanks.
– Octopus
May 22 '14 at 19:34
This won't work because the Pre's don't start in a defined order. You should use instead/bin/install -d -o uswsgi -g uwsgi -m 0770 /run/uwsgi
– Otheus
Nov 10 '16 at 20:31
@Otheus, I'm not sure about the accuracy of your statement. As jsbillings states, this is exactly what you end up with when you use the yum package manager on Fedora 20.
– Octopus
Nov 10 '16 at 21:24
I retract my previous comment. The systemd man page and evidence from 2011 show statements are executed "one after the other, serially". lists.fedoraproject.org/pipermail/devel/2011-July/153897.html Though I had evidence to the contrary, I'm not sure where that evidence is.
– Otheus
Nov 13 '16 at 13:03
add a comment |
Multiple ExecStartPre's command are not always executed in the same order as they are listed in the .service file.
What works is to combine all commands into a single sh invocation, like this:
ExecStartPre=/bin/sh -c 'mkdir -p /run/uwsgi ; chown uwsgi:uwsgi /run/uwsgi'
2
Why do people not know aboutinstall
??/bin/install -d -o uswsgi -g uwsgi -m 0770 /run/uwsgi
– Otheus
Nov 10 '16 at 20:34
add a comment |
The uwsgi
package I was installing—the default one on CentOS 7—already included the correct /usr/lib/tmpfiles.d/uwsgi.conf
file. But the directory was still not there. A reboot probably would have caused it to be created when systemd-tmpfiles
started up fresh, but in my case—
I needed to run
systemd-tmpfiles --create
after installing the package in order to create the directory right away.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f125286%2fwhats-the-best-way-to-have-uwsgi-create-a-run-uwsgi-folder-on-reboot%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
From tmpfiles.d(5):
System daemons frequently require private runtime directories below /run to place communication sockets and similar in. For these, consider declaring them in their unit files using RuntimeDirectory= (see systemd.exec(5) for details), if this is feasible.
And from systemd.exec(5):
RuntimeDirectory=, RuntimeDirectoryMode=
Takes a list of directory names. If set, one or more directories by the specified names will be created below /run (for system services) or below $XDG_RUNTIME_DIR (for user services) when the unit is started, and removed when the unit is stopped. The directories will have the access mode specified in RuntimeDirectoryMode=, and will be owned by the user and group specified in User= and Group=. Use this to manage one or more runtime directories of the unit and bind their lifetime to the daemon runtime.
In other words, while using tmpfiles.d for this "works", the officially recommended way is to add
RuntimeDirectory=uwsgi
to the [Service]
section of your unit file.
This has the advantage that it is briefer, guarantees that it's created with the correct user/group ownership, and cleans up the directory when the daemon is stopped.
Note that these options were added in a relatively recent version of systemd and may not be in the version on your server. Check your local man page for systemd.exec. if it's not there, you can't use it.
– Eddie
Jun 22 '15 at 22:58
This is the answer!
– ATOzTOA
Oct 7 '16 at 0:15
Yep. But watch it: those systemd parameters are f'king case-sensitive. And don't forget to dodaemon-reload
– Otheus
Nov 10 '16 at 20:42
add a comment |
From tmpfiles.d(5):
System daemons frequently require private runtime directories below /run to place communication sockets and similar in. For these, consider declaring them in their unit files using RuntimeDirectory= (see systemd.exec(5) for details), if this is feasible.
And from systemd.exec(5):
RuntimeDirectory=, RuntimeDirectoryMode=
Takes a list of directory names. If set, one or more directories by the specified names will be created below /run (for system services) or below $XDG_RUNTIME_DIR (for user services) when the unit is started, and removed when the unit is stopped. The directories will have the access mode specified in RuntimeDirectoryMode=, and will be owned by the user and group specified in User= and Group=. Use this to manage one or more runtime directories of the unit and bind their lifetime to the daemon runtime.
In other words, while using tmpfiles.d for this "works", the officially recommended way is to add
RuntimeDirectory=uwsgi
to the [Service]
section of your unit file.
This has the advantage that it is briefer, guarantees that it's created with the correct user/group ownership, and cleans up the directory when the daemon is stopped.
Note that these options were added in a relatively recent version of systemd and may not be in the version on your server. Check your local man page for systemd.exec. if it's not there, you can't use it.
– Eddie
Jun 22 '15 at 22:58
This is the answer!
– ATOzTOA
Oct 7 '16 at 0:15
Yep. But watch it: those systemd parameters are f'king case-sensitive. And don't forget to dodaemon-reload
– Otheus
Nov 10 '16 at 20:42
add a comment |
From tmpfiles.d(5):
System daemons frequently require private runtime directories below /run to place communication sockets and similar in. For these, consider declaring them in their unit files using RuntimeDirectory= (see systemd.exec(5) for details), if this is feasible.
And from systemd.exec(5):
RuntimeDirectory=, RuntimeDirectoryMode=
Takes a list of directory names. If set, one or more directories by the specified names will be created below /run (for system services) or below $XDG_RUNTIME_DIR (for user services) when the unit is started, and removed when the unit is stopped. The directories will have the access mode specified in RuntimeDirectoryMode=, and will be owned by the user and group specified in User= and Group=. Use this to manage one or more runtime directories of the unit and bind their lifetime to the daemon runtime.
In other words, while using tmpfiles.d for this "works", the officially recommended way is to add
RuntimeDirectory=uwsgi
to the [Service]
section of your unit file.
This has the advantage that it is briefer, guarantees that it's created with the correct user/group ownership, and cleans up the directory when the daemon is stopped.
From tmpfiles.d(5):
System daemons frequently require private runtime directories below /run to place communication sockets and similar in. For these, consider declaring them in their unit files using RuntimeDirectory= (see systemd.exec(5) for details), if this is feasible.
And from systemd.exec(5):
RuntimeDirectory=, RuntimeDirectoryMode=
Takes a list of directory names. If set, one or more directories by the specified names will be created below /run (for system services) or below $XDG_RUNTIME_DIR (for user services) when the unit is started, and removed when the unit is stopped. The directories will have the access mode specified in RuntimeDirectoryMode=, and will be owned by the user and group specified in User= and Group=. Use this to manage one or more runtime directories of the unit and bind their lifetime to the daemon runtime.
In other words, while using tmpfiles.d for this "works", the officially recommended way is to add
RuntimeDirectory=uwsgi
to the [Service]
section of your unit file.
This has the advantage that it is briefer, guarantees that it's created with the correct user/group ownership, and cleans up the directory when the daemon is stopped.
edited Jun 13 '15 at 7:00
answered Jun 13 '15 at 2:05
kevmitchkevmitch
25025
25025
Note that these options were added in a relatively recent version of systemd and may not be in the version on your server. Check your local man page for systemd.exec. if it's not there, you can't use it.
– Eddie
Jun 22 '15 at 22:58
This is the answer!
– ATOzTOA
Oct 7 '16 at 0:15
Yep. But watch it: those systemd parameters are f'king case-sensitive. And don't forget to dodaemon-reload
– Otheus
Nov 10 '16 at 20:42
add a comment |
Note that these options were added in a relatively recent version of systemd and may not be in the version on your server. Check your local man page for systemd.exec. if it's not there, you can't use it.
– Eddie
Jun 22 '15 at 22:58
This is the answer!
– ATOzTOA
Oct 7 '16 at 0:15
Yep. But watch it: those systemd parameters are f'king case-sensitive. And don't forget to dodaemon-reload
– Otheus
Nov 10 '16 at 20:42
Note that these options were added in a relatively recent version of systemd and may not be in the version on your server. Check your local man page for systemd.exec. if it's not there, you can't use it.
– Eddie
Jun 22 '15 at 22:58
Note that these options were added in a relatively recent version of systemd and may not be in the version on your server. Check your local man page for systemd.exec. if it's not there, you can't use it.
– Eddie
Jun 22 '15 at 22:58
This is the answer!
– ATOzTOA
Oct 7 '16 at 0:15
This is the answer!
– ATOzTOA
Oct 7 '16 at 0:15
Yep. But watch it: those systemd parameters are f'king case-sensitive. And don't forget to do
daemon-reload
– Otheus
Nov 10 '16 at 20:42
Yep. But watch it: those systemd parameters are f'king case-sensitive. And don't forget to do
daemon-reload
– Otheus
Nov 10 '16 at 20:42
add a comment |
You need to create a configuration file under /etc/tmpfiles.d/
defining that this directory should be created by systemd during boot/startup.
Example
$ more /etc/tmpfiles.d/uwsgi.conf
D /run/uwsgi 0770 uwsgi uwsgi -
Set it with whatever ownership/permissions you deem are appropriate for your situation.
NOTE: If you use the setup I provided above then you'll likely want to add the group uwsgi
to Nginx's user nginx
:
$ sudo usermod -a nginx -G uwsgi
References
- Adding the Emperor to systemd
- The uWSGI Emperor – multi-app deployment
add a comment |
You need to create a configuration file under /etc/tmpfiles.d/
defining that this directory should be created by systemd during boot/startup.
Example
$ more /etc/tmpfiles.d/uwsgi.conf
D /run/uwsgi 0770 uwsgi uwsgi -
Set it with whatever ownership/permissions you deem are appropriate for your situation.
NOTE: If you use the setup I provided above then you'll likely want to add the group uwsgi
to Nginx's user nginx
:
$ sudo usermod -a nginx -G uwsgi
References
- Adding the Emperor to systemd
- The uWSGI Emperor – multi-app deployment
add a comment |
You need to create a configuration file under /etc/tmpfiles.d/
defining that this directory should be created by systemd during boot/startup.
Example
$ more /etc/tmpfiles.d/uwsgi.conf
D /run/uwsgi 0770 uwsgi uwsgi -
Set it with whatever ownership/permissions you deem are appropriate for your situation.
NOTE: If you use the setup I provided above then you'll likely want to add the group uwsgi
to Nginx's user nginx
:
$ sudo usermod -a nginx -G uwsgi
References
- Adding the Emperor to systemd
- The uWSGI Emperor – multi-app deployment
You need to create a configuration file under /etc/tmpfiles.d/
defining that this directory should be created by systemd during boot/startup.
Example
$ more /etc/tmpfiles.d/uwsgi.conf
D /run/uwsgi 0770 uwsgi uwsgi -
Set it with whatever ownership/permissions you deem are appropriate for your situation.
NOTE: If you use the setup I provided above then you'll likely want to add the group uwsgi
to Nginx's user nginx
:
$ sudo usermod -a nginx -G uwsgi
References
- Adding the Emperor to systemd
- The uWSGI Emperor – multi-app deployment
edited Apr 18 '14 at 3:07
answered Apr 18 '14 at 2:55
slm♦slm
248k66516678
248k66516678
add a comment |
add a comment |
The way I eventually solved this problem was to use the latest distributions. Fedora 20 and yum install uwsgi
built an environment where all of these details were handled automatically for me, while I was previously trying to fudge this onto a Fedora17 system where it wasn't available in the yum repositories.
The way Fedora 20 solves this is by having this in its uwsgi service unit:
ExecStartPre=/bin/mkdir -p /run/uwsgi
ExecStartPre=/bin/chown uwsgi:uwsgi /run/uwsgi
1
The way Fedora 20 solves this is by having this in its uwsgi service unit:ExecStartPre=/bin/mkdir -p /run/uwsgi
ExecStartPre=/bin/chown uwsgi:uwsgi /run/uwsgi
– jsbillings
May 22 '14 at 19:28
1
Yes, definitely worth mentioning that in the answer, thanks.
– Octopus
May 22 '14 at 19:34
This won't work because the Pre's don't start in a defined order. You should use instead/bin/install -d -o uswsgi -g uwsgi -m 0770 /run/uwsgi
– Otheus
Nov 10 '16 at 20:31
@Otheus, I'm not sure about the accuracy of your statement. As jsbillings states, this is exactly what you end up with when you use the yum package manager on Fedora 20.
– Octopus
Nov 10 '16 at 21:24
I retract my previous comment. The systemd man page and evidence from 2011 show statements are executed "one after the other, serially". lists.fedoraproject.org/pipermail/devel/2011-July/153897.html Though I had evidence to the contrary, I'm not sure where that evidence is.
– Otheus
Nov 13 '16 at 13:03
add a comment |
The way I eventually solved this problem was to use the latest distributions. Fedora 20 and yum install uwsgi
built an environment where all of these details were handled automatically for me, while I was previously trying to fudge this onto a Fedora17 system where it wasn't available in the yum repositories.
The way Fedora 20 solves this is by having this in its uwsgi service unit:
ExecStartPre=/bin/mkdir -p /run/uwsgi
ExecStartPre=/bin/chown uwsgi:uwsgi /run/uwsgi
1
The way Fedora 20 solves this is by having this in its uwsgi service unit:ExecStartPre=/bin/mkdir -p /run/uwsgi
ExecStartPre=/bin/chown uwsgi:uwsgi /run/uwsgi
– jsbillings
May 22 '14 at 19:28
1
Yes, definitely worth mentioning that in the answer, thanks.
– Octopus
May 22 '14 at 19:34
This won't work because the Pre's don't start in a defined order. You should use instead/bin/install -d -o uswsgi -g uwsgi -m 0770 /run/uwsgi
– Otheus
Nov 10 '16 at 20:31
@Otheus, I'm not sure about the accuracy of your statement. As jsbillings states, this is exactly what you end up with when you use the yum package manager on Fedora 20.
– Octopus
Nov 10 '16 at 21:24
I retract my previous comment. The systemd man page and evidence from 2011 show statements are executed "one after the other, serially". lists.fedoraproject.org/pipermail/devel/2011-July/153897.html Though I had evidence to the contrary, I'm not sure where that evidence is.
– Otheus
Nov 13 '16 at 13:03
add a comment |
The way I eventually solved this problem was to use the latest distributions. Fedora 20 and yum install uwsgi
built an environment where all of these details were handled automatically for me, while I was previously trying to fudge this onto a Fedora17 system where it wasn't available in the yum repositories.
The way Fedora 20 solves this is by having this in its uwsgi service unit:
ExecStartPre=/bin/mkdir -p /run/uwsgi
ExecStartPre=/bin/chown uwsgi:uwsgi /run/uwsgi
The way I eventually solved this problem was to use the latest distributions. Fedora 20 and yum install uwsgi
built an environment where all of these details were handled automatically for me, while I was previously trying to fudge this onto a Fedora17 system where it wasn't available in the yum repositories.
The way Fedora 20 solves this is by having this in its uwsgi service unit:
ExecStartPre=/bin/mkdir -p /run/uwsgi
ExecStartPre=/bin/chown uwsgi:uwsgi /run/uwsgi
edited May 22 '14 at 19:34
answered May 22 '14 at 18:08
OctopusOctopus
94251322
94251322
1
The way Fedora 20 solves this is by having this in its uwsgi service unit:ExecStartPre=/bin/mkdir -p /run/uwsgi
ExecStartPre=/bin/chown uwsgi:uwsgi /run/uwsgi
– jsbillings
May 22 '14 at 19:28
1
Yes, definitely worth mentioning that in the answer, thanks.
– Octopus
May 22 '14 at 19:34
This won't work because the Pre's don't start in a defined order. You should use instead/bin/install -d -o uswsgi -g uwsgi -m 0770 /run/uwsgi
– Otheus
Nov 10 '16 at 20:31
@Otheus, I'm not sure about the accuracy of your statement. As jsbillings states, this is exactly what you end up with when you use the yum package manager on Fedora 20.
– Octopus
Nov 10 '16 at 21:24
I retract my previous comment. The systemd man page and evidence from 2011 show statements are executed "one after the other, serially". lists.fedoraproject.org/pipermail/devel/2011-July/153897.html Though I had evidence to the contrary, I'm not sure where that evidence is.
– Otheus
Nov 13 '16 at 13:03
add a comment |
1
The way Fedora 20 solves this is by having this in its uwsgi service unit:ExecStartPre=/bin/mkdir -p /run/uwsgi
ExecStartPre=/bin/chown uwsgi:uwsgi /run/uwsgi
– jsbillings
May 22 '14 at 19:28
1
Yes, definitely worth mentioning that in the answer, thanks.
– Octopus
May 22 '14 at 19:34
This won't work because the Pre's don't start in a defined order. You should use instead/bin/install -d -o uswsgi -g uwsgi -m 0770 /run/uwsgi
– Otheus
Nov 10 '16 at 20:31
@Otheus, I'm not sure about the accuracy of your statement. As jsbillings states, this is exactly what you end up with when you use the yum package manager on Fedora 20.
– Octopus
Nov 10 '16 at 21:24
I retract my previous comment. The systemd man page and evidence from 2011 show statements are executed "one after the other, serially". lists.fedoraproject.org/pipermail/devel/2011-July/153897.html Though I had evidence to the contrary, I'm not sure where that evidence is.
– Otheus
Nov 13 '16 at 13:03
1
1
The way Fedora 20 solves this is by having this in its uwsgi service unit:
ExecStartPre=/bin/mkdir -p /run/uwsgi
ExecStartPre=/bin/chown uwsgi:uwsgi /run/uwsgi
– jsbillings
May 22 '14 at 19:28
The way Fedora 20 solves this is by having this in its uwsgi service unit:
ExecStartPre=/bin/mkdir -p /run/uwsgi
ExecStartPre=/bin/chown uwsgi:uwsgi /run/uwsgi
– jsbillings
May 22 '14 at 19:28
1
1
Yes, definitely worth mentioning that in the answer, thanks.
– Octopus
May 22 '14 at 19:34
Yes, definitely worth mentioning that in the answer, thanks.
– Octopus
May 22 '14 at 19:34
This won't work because the Pre's don't start in a defined order. You should use instead
/bin/install -d -o uswsgi -g uwsgi -m 0770 /run/uwsgi
– Otheus
Nov 10 '16 at 20:31
This won't work because the Pre's don't start in a defined order. You should use instead
/bin/install -d -o uswsgi -g uwsgi -m 0770 /run/uwsgi
– Otheus
Nov 10 '16 at 20:31
@Otheus, I'm not sure about the accuracy of your statement. As jsbillings states, this is exactly what you end up with when you use the yum package manager on Fedora 20.
– Octopus
Nov 10 '16 at 21:24
@Otheus, I'm not sure about the accuracy of your statement. As jsbillings states, this is exactly what you end up with when you use the yum package manager on Fedora 20.
– Octopus
Nov 10 '16 at 21:24
I retract my previous comment. The systemd man page and evidence from 2011 show statements are executed "one after the other, serially". lists.fedoraproject.org/pipermail/devel/2011-July/153897.html Though I had evidence to the contrary, I'm not sure where that evidence is.
– Otheus
Nov 13 '16 at 13:03
I retract my previous comment. The systemd man page and evidence from 2011 show statements are executed "one after the other, serially". lists.fedoraproject.org/pipermail/devel/2011-July/153897.html Though I had evidence to the contrary, I'm not sure where that evidence is.
– Otheus
Nov 13 '16 at 13:03
add a comment |
Multiple ExecStartPre's command are not always executed in the same order as they are listed in the .service file.
What works is to combine all commands into a single sh invocation, like this:
ExecStartPre=/bin/sh -c 'mkdir -p /run/uwsgi ; chown uwsgi:uwsgi /run/uwsgi'
2
Why do people not know aboutinstall
??/bin/install -d -o uswsgi -g uwsgi -m 0770 /run/uwsgi
– Otheus
Nov 10 '16 at 20:34
add a comment |
Multiple ExecStartPre's command are not always executed in the same order as they are listed in the .service file.
What works is to combine all commands into a single sh invocation, like this:
ExecStartPre=/bin/sh -c 'mkdir -p /run/uwsgi ; chown uwsgi:uwsgi /run/uwsgi'
2
Why do people not know aboutinstall
??/bin/install -d -o uswsgi -g uwsgi -m 0770 /run/uwsgi
– Otheus
Nov 10 '16 at 20:34
add a comment |
Multiple ExecStartPre's command are not always executed in the same order as they are listed in the .service file.
What works is to combine all commands into a single sh invocation, like this:
ExecStartPre=/bin/sh -c 'mkdir -p /run/uwsgi ; chown uwsgi:uwsgi /run/uwsgi'
Multiple ExecStartPre's command are not always executed in the same order as they are listed in the .service file.
What works is to combine all commands into a single sh invocation, like this:
ExecStartPre=/bin/sh -c 'mkdir -p /run/uwsgi ; chown uwsgi:uwsgi /run/uwsgi'
answered Jan 23 '16 at 19:32
R. TomaR. Toma
1
1
2
Why do people not know aboutinstall
??/bin/install -d -o uswsgi -g uwsgi -m 0770 /run/uwsgi
– Otheus
Nov 10 '16 at 20:34
add a comment |
2
Why do people not know aboutinstall
??/bin/install -d -o uswsgi -g uwsgi -m 0770 /run/uwsgi
– Otheus
Nov 10 '16 at 20:34
2
2
Why do people not know about
install
?? /bin/install -d -o uswsgi -g uwsgi -m 0770 /run/uwsgi
– Otheus
Nov 10 '16 at 20:34
Why do people not know about
install
?? /bin/install -d -o uswsgi -g uwsgi -m 0770 /run/uwsgi
– Otheus
Nov 10 '16 at 20:34
add a comment |
The uwsgi
package I was installing—the default one on CentOS 7—already included the correct /usr/lib/tmpfiles.d/uwsgi.conf
file. But the directory was still not there. A reboot probably would have caused it to be created when systemd-tmpfiles
started up fresh, but in my case—
I needed to run
systemd-tmpfiles --create
after installing the package in order to create the directory right away.
add a comment |
The uwsgi
package I was installing—the default one on CentOS 7—already included the correct /usr/lib/tmpfiles.d/uwsgi.conf
file. But the directory was still not there. A reboot probably would have caused it to be created when systemd-tmpfiles
started up fresh, but in my case—
I needed to run
systemd-tmpfiles --create
after installing the package in order to create the directory right away.
add a comment |
The uwsgi
package I was installing—the default one on CentOS 7—already included the correct /usr/lib/tmpfiles.d/uwsgi.conf
file. But the directory was still not there. A reboot probably would have caused it to be created when systemd-tmpfiles
started up fresh, but in my case—
I needed to run
systemd-tmpfiles --create
after installing the package in order to create the directory right away.
The uwsgi
package I was installing—the default one on CentOS 7—already included the correct /usr/lib/tmpfiles.d/uwsgi.conf
file. But the directory was still not there. A reboot probably would have caused it to be created when systemd-tmpfiles
started up fresh, but in my case—
I needed to run
systemd-tmpfiles --create
after installing the package in order to create the directory right away.
answered Jan 2 at 3:22
andrewandrew
1011
1011
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f125286%2fwhats-the-best-way-to-have-uwsgi-create-a-run-uwsgi-folder-on-reboot%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I am not aware of
uwsgi
but if the program runs fine as long as/run/uwsgi
folder is present, you can addmkdir /run/uwsgi
to your/etc/rc.local
file and every time when the system reboots, the folder would be created.– Ramesh
Apr 17 '14 at 20:39
@Ramesh, that happens too late. The folder is created by /etc/rc.local, but systemd has already tried to init the module and failed.
– Octopus
Apr 17 '14 at 21:06
You probably need to add the run control script to
/etc/init.d
. You can find more information regarding the same from here. docs.oracle.com/cd/E19683-01/806-4073/6jd67r96g/index.html– Ramesh
Apr 17 '14 at 22:14
What is your distribution?
/run
should be created fairly early on by the boot scripts. Do you have an older distribution that doesn't create/run
at all, or is your problem arranging to start uswgi late enough?– Gilles
Apr 17 '14 at 23:55
1
@Gilles, /run is created. i want to also create /run/uwsgi/ at roughly the same time. or at least before systemd loads modules. this is on fedora 16 and later (i'd prefer a solution that is generally os agnostic)
– Octopus
Apr 18 '14 at 1:24