How to automatically create a runtime folder with a systemd service or tmpfiles.d?systemd: permission issue...
Polygons crash kernel?
Gödel's paradox: Why is "a proof that some universal statement is unprovable" not a valid proof that this statement is true?
Why does the friction act on the inward direction when a car makes a turn on a level road?
How to handle many times series?
What is Albrecht Dürer's Perspective Machine drawing style?
In a KP-K endgame, if the enemy king is in front of the pawn, is it always a draw?
Does WSL2 runs Linux in a virtual machine or alongside windows Kernel?
A wiild aanimal, a cardinal direction, or a place by the water
Different answers of calculations in LuaLaTeX on local computer, lua compiler and on overleaf
Meaning of ギャップ in the following sentence
Is Norway in the Single Market?
Can't understand an ACT practice problem: Triangle appears to be isosceles, why isn't the answer 7.3~ here?
Reasons for using monsters as bioweapons
What printing process is this?
Generate random number in Unity without class ambiguity
Why did the United States not resort to nuclear weapons in Vietnam?
Why do my fried eggs start browning very fast?
Have you been refused entry into the Federal Republic of Germany?
Approximating an expression for a potential
On the expression "sun-down"
What exactly is Rhumb-line control in the context of a launch trajectory?
Astable 555 circuit not oscillating
What does Argus Filch specifically do?
Pronouns when writing from the point of view of a robot
How to automatically create a runtime folder with a systemd service or tmpfiles.d?
systemd: permission issue with mkdir & ExecStartPreWhat's the best way to have uwsgi create a '/run/uwsgi' folder on reboot?How do I start service in systemd right after cryptsetup?Self-restarting service does not restart with systemdMake systemd reload only single openvpn process and not the whole groupsystemd and OpenVPN woes after an Ubuntu upgradeHow to restart systemd service after files update under Gunicorn server?On-demand SSH Socks proxy through systemd user units with socket-activation doesn't restart as wishedWhy is systemd stopping service immediately after it is started?Confusing systemd behaviour with OnFailure= and Restart=Stopping systemd unit together with another. Starting worksSetting up Apache Superset as a Systemd Service
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I'm trying to create a runtime folder at /run/gunicorn
for some Gunicorn socket / PID files, which are for a Django application. I can get everything working if I manually create directories. However, I'm trying to make this a robust setup, and eventually use Ansible to automate everything.
I think I have 2 options, based on this question.
Option 1 - RuntimeDirectory
I think the first option is to use RuntimeDirectory=
within my systemd service file, but I can't get it to create the folder. The service files contains:
#/etc/systemd/system/gunicorn_django_test.service
[Unit]
Description=gunicorn_django daemon
After=network.target
[Service]
User=gunicorn
Group=www-data
RuntimeDirectory=gunicorn #This line is supposed to create a directory
RuntimeDirectoryMode=755
PIDFile=/run/gunicorn/django_test_pid
WorkingDirectory=/vagrant/webapps/django_venv/django_test
ExecStart=/vagrant/webapps/django_venv/bin/gunicorn --pid /run/gunicorn/django_test_pid --workers 3 --bind unix:/run/gunicorn/django_test_socket django_test.wsgi --error-logfile /var/log/gunicorn/django_test_error.log
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
When I run systemctl start gunicorn_django_test.service
, the service fails to start. When I snip out the exec line, and run it manually, I get Error: /run/gunicorn doesn't exist. Can't create pidfile.
If I create the /run/gunicorn
folder manually, I can get things to work.
Option 2 - tmpfiles.d
The second option is to use tmpfiles.d
to have a folder created on boot, ready for the pid / socket files. I've tried this file:
#/etc/tmpfiles.d/gunicorn.conf
d /run/gunicorn 0755 gunicorn www-data -
This creates a directory, but it is quicklydeleted somehow, and by the time I start the service, the folder isn't available.
I can manually add some PreExec mkdir
commands into the service file, but I'd like to get to the bottom of why RuntimeDirectory / tmpfiles.d aren't working. Thanks.
Versions / Info:
Ubuntu 16.04 Server / systemd 229 / Gunicorn 19.7.1 / runtime dir = /run
ubuntu systemd python socket
add a comment |
I'm trying to create a runtime folder at /run/gunicorn
for some Gunicorn socket / PID files, which are for a Django application. I can get everything working if I manually create directories. However, I'm trying to make this a robust setup, and eventually use Ansible to automate everything.
I think I have 2 options, based on this question.
Option 1 - RuntimeDirectory
I think the first option is to use RuntimeDirectory=
within my systemd service file, but I can't get it to create the folder. The service files contains:
#/etc/systemd/system/gunicorn_django_test.service
[Unit]
Description=gunicorn_django daemon
After=network.target
[Service]
User=gunicorn
Group=www-data
RuntimeDirectory=gunicorn #This line is supposed to create a directory
RuntimeDirectoryMode=755
PIDFile=/run/gunicorn/django_test_pid
WorkingDirectory=/vagrant/webapps/django_venv/django_test
ExecStart=/vagrant/webapps/django_venv/bin/gunicorn --pid /run/gunicorn/django_test_pid --workers 3 --bind unix:/run/gunicorn/django_test_socket django_test.wsgi --error-logfile /var/log/gunicorn/django_test_error.log
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
When I run systemctl start gunicorn_django_test.service
, the service fails to start. When I snip out the exec line, and run it manually, I get Error: /run/gunicorn doesn't exist. Can't create pidfile.
If I create the /run/gunicorn
folder manually, I can get things to work.
Option 2 - tmpfiles.d
The second option is to use tmpfiles.d
to have a folder created on boot, ready for the pid / socket files. I've tried this file:
#/etc/tmpfiles.d/gunicorn.conf
d /run/gunicorn 0755 gunicorn www-data -
This creates a directory, but it is quicklydeleted somehow, and by the time I start the service, the folder isn't available.
I can manually add some PreExec mkdir
commands into the service file, but I'd like to get to the bottom of why RuntimeDirectory / tmpfiles.d aren't working. Thanks.
Versions / Info:
Ubuntu 16.04 Server / systemd 229 / Gunicorn 19.7.1 / runtime dir = /run
ubuntu systemd python socket
1
It's something to do with group permissions in the /run/ folder. I can create a 0755 folder with the group aswww-data
, but I need the folder to be group writeable, so both the Nginx user and the Gunicorn user can access the socket file. In order to do that, I need sudo-level permissions. For some reason,sudo systemctl... etc
isn't passing the sudo permissions to the service.
– geonaut
Mar 29 '17 at 15:47
2
i'll bet it's trying to create the directory with the uid fromUser=
and failing. try addingPermissionsStartOnly=true
. see unix.stackexchange.com/a/207493/222377
– quixotic
Mar 29 '17 at 17:07
hmm. actually i'll bet it's failing because the runtime directory is made but isn't/run/gunicorn
. it's probably$XDG_RUNTIME_DIR/gunicorn
which might resolve to/run/user/$UID/gunicorn
for thegunicorn
user UID. (same question, next answer.)
– quixotic
Mar 29 '17 at 17:16
Are you trying to use the same directory for multiple Gunicorn instances? You could be running into this related issue>
– Mark Stosberg
Mar 29 '17 at 17:22
Your Option 2 would have worked. However, thetmpfiles.d
andRuntimeDirectory=...
definitions are not compatible. You should not have both turned on at the same time.
– Alexis Wilke
Oct 26 '18 at 8:02
add a comment |
I'm trying to create a runtime folder at /run/gunicorn
for some Gunicorn socket / PID files, which are for a Django application. I can get everything working if I manually create directories. However, I'm trying to make this a robust setup, and eventually use Ansible to automate everything.
I think I have 2 options, based on this question.
Option 1 - RuntimeDirectory
I think the first option is to use RuntimeDirectory=
within my systemd service file, but I can't get it to create the folder. The service files contains:
#/etc/systemd/system/gunicorn_django_test.service
[Unit]
Description=gunicorn_django daemon
After=network.target
[Service]
User=gunicorn
Group=www-data
RuntimeDirectory=gunicorn #This line is supposed to create a directory
RuntimeDirectoryMode=755
PIDFile=/run/gunicorn/django_test_pid
WorkingDirectory=/vagrant/webapps/django_venv/django_test
ExecStart=/vagrant/webapps/django_venv/bin/gunicorn --pid /run/gunicorn/django_test_pid --workers 3 --bind unix:/run/gunicorn/django_test_socket django_test.wsgi --error-logfile /var/log/gunicorn/django_test_error.log
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
When I run systemctl start gunicorn_django_test.service
, the service fails to start. When I snip out the exec line, and run it manually, I get Error: /run/gunicorn doesn't exist. Can't create pidfile.
If I create the /run/gunicorn
folder manually, I can get things to work.
Option 2 - tmpfiles.d
The second option is to use tmpfiles.d
to have a folder created on boot, ready for the pid / socket files. I've tried this file:
#/etc/tmpfiles.d/gunicorn.conf
d /run/gunicorn 0755 gunicorn www-data -
This creates a directory, but it is quicklydeleted somehow, and by the time I start the service, the folder isn't available.
I can manually add some PreExec mkdir
commands into the service file, but I'd like to get to the bottom of why RuntimeDirectory / tmpfiles.d aren't working. Thanks.
Versions / Info:
Ubuntu 16.04 Server / systemd 229 / Gunicorn 19.7.1 / runtime dir = /run
ubuntu systemd python socket
I'm trying to create a runtime folder at /run/gunicorn
for some Gunicorn socket / PID files, which are for a Django application. I can get everything working if I manually create directories. However, I'm trying to make this a robust setup, and eventually use Ansible to automate everything.
I think I have 2 options, based on this question.
Option 1 - RuntimeDirectory
I think the first option is to use RuntimeDirectory=
within my systemd service file, but I can't get it to create the folder. The service files contains:
#/etc/systemd/system/gunicorn_django_test.service
[Unit]
Description=gunicorn_django daemon
After=network.target
[Service]
User=gunicorn
Group=www-data
RuntimeDirectory=gunicorn #This line is supposed to create a directory
RuntimeDirectoryMode=755
PIDFile=/run/gunicorn/django_test_pid
WorkingDirectory=/vagrant/webapps/django_venv/django_test
ExecStart=/vagrant/webapps/django_venv/bin/gunicorn --pid /run/gunicorn/django_test_pid --workers 3 --bind unix:/run/gunicorn/django_test_socket django_test.wsgi --error-logfile /var/log/gunicorn/django_test_error.log
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
When I run systemctl start gunicorn_django_test.service
, the service fails to start. When I snip out the exec line, and run it manually, I get Error: /run/gunicorn doesn't exist. Can't create pidfile.
If I create the /run/gunicorn
folder manually, I can get things to work.
Option 2 - tmpfiles.d
The second option is to use tmpfiles.d
to have a folder created on boot, ready for the pid / socket files. I've tried this file:
#/etc/tmpfiles.d/gunicorn.conf
d /run/gunicorn 0755 gunicorn www-data -
This creates a directory, but it is quicklydeleted somehow, and by the time I start the service, the folder isn't available.
I can manually add some PreExec mkdir
commands into the service file, but I'd like to get to the bottom of why RuntimeDirectory / tmpfiles.d aren't working. Thanks.
Versions / Info:
Ubuntu 16.04 Server / systemd 229 / Gunicorn 19.7.1 / runtime dir = /run
ubuntu systemd python socket
ubuntu systemd python socket
edited Mar 29 '17 at 15:44
geonaut
asked Mar 29 '17 at 13:38
geonautgeonaut
1011 silver badge7 bronze badges
1011 silver badge7 bronze badges
1
It's something to do with group permissions in the /run/ folder. I can create a 0755 folder with the group aswww-data
, but I need the folder to be group writeable, so both the Nginx user and the Gunicorn user can access the socket file. In order to do that, I need sudo-level permissions. For some reason,sudo systemctl... etc
isn't passing the sudo permissions to the service.
– geonaut
Mar 29 '17 at 15:47
2
i'll bet it's trying to create the directory with the uid fromUser=
and failing. try addingPermissionsStartOnly=true
. see unix.stackexchange.com/a/207493/222377
– quixotic
Mar 29 '17 at 17:07
hmm. actually i'll bet it's failing because the runtime directory is made but isn't/run/gunicorn
. it's probably$XDG_RUNTIME_DIR/gunicorn
which might resolve to/run/user/$UID/gunicorn
for thegunicorn
user UID. (same question, next answer.)
– quixotic
Mar 29 '17 at 17:16
Are you trying to use the same directory for multiple Gunicorn instances? You could be running into this related issue>
– Mark Stosberg
Mar 29 '17 at 17:22
Your Option 2 would have worked. However, thetmpfiles.d
andRuntimeDirectory=...
definitions are not compatible. You should not have both turned on at the same time.
– Alexis Wilke
Oct 26 '18 at 8:02
add a comment |
1
It's something to do with group permissions in the /run/ folder. I can create a 0755 folder with the group aswww-data
, but I need the folder to be group writeable, so both the Nginx user and the Gunicorn user can access the socket file. In order to do that, I need sudo-level permissions. For some reason,sudo systemctl... etc
isn't passing the sudo permissions to the service.
– geonaut
Mar 29 '17 at 15:47
2
i'll bet it's trying to create the directory with the uid fromUser=
and failing. try addingPermissionsStartOnly=true
. see unix.stackexchange.com/a/207493/222377
– quixotic
Mar 29 '17 at 17:07
hmm. actually i'll bet it's failing because the runtime directory is made but isn't/run/gunicorn
. it's probably$XDG_RUNTIME_DIR/gunicorn
which might resolve to/run/user/$UID/gunicorn
for thegunicorn
user UID. (same question, next answer.)
– quixotic
Mar 29 '17 at 17:16
Are you trying to use the same directory for multiple Gunicorn instances? You could be running into this related issue>
– Mark Stosberg
Mar 29 '17 at 17:22
Your Option 2 would have worked. However, thetmpfiles.d
andRuntimeDirectory=...
definitions are not compatible. You should not have both turned on at the same time.
– Alexis Wilke
Oct 26 '18 at 8:02
1
1
It's something to do with group permissions in the /run/ folder. I can create a 0755 folder with the group as
www-data
, but I need the folder to be group writeable, so both the Nginx user and the Gunicorn user can access the socket file. In order to do that, I need sudo-level permissions. For some reason, sudo systemctl... etc
isn't passing the sudo permissions to the service.– geonaut
Mar 29 '17 at 15:47
It's something to do with group permissions in the /run/ folder. I can create a 0755 folder with the group as
www-data
, but I need the folder to be group writeable, so both the Nginx user and the Gunicorn user can access the socket file. In order to do that, I need sudo-level permissions. For some reason, sudo systemctl... etc
isn't passing the sudo permissions to the service.– geonaut
Mar 29 '17 at 15:47
2
2
i'll bet it's trying to create the directory with the uid from
User=
and failing. try adding PermissionsStartOnly=true
. see unix.stackexchange.com/a/207493/222377– quixotic
Mar 29 '17 at 17:07
i'll bet it's trying to create the directory with the uid from
User=
and failing. try adding PermissionsStartOnly=true
. see unix.stackexchange.com/a/207493/222377– quixotic
Mar 29 '17 at 17:07
hmm. actually i'll bet it's failing because the runtime directory is made but isn't
/run/gunicorn
. it's probably $XDG_RUNTIME_DIR/gunicorn
which might resolve to /run/user/$UID/gunicorn
for the gunicorn
user UID. (same question, next answer.)– quixotic
Mar 29 '17 at 17:16
hmm. actually i'll bet it's failing because the runtime directory is made but isn't
/run/gunicorn
. it's probably $XDG_RUNTIME_DIR/gunicorn
which might resolve to /run/user/$UID/gunicorn
for the gunicorn
user UID. (same question, next answer.)– quixotic
Mar 29 '17 at 17:16
Are you trying to use the same directory for multiple Gunicorn instances? You could be running into this related issue>
– Mark Stosberg
Mar 29 '17 at 17:22
Are you trying to use the same directory for multiple Gunicorn instances? You could be running into this related issue>
– Mark Stosberg
Mar 29 '17 at 17:22
Your Option 2 would have worked. However, the
tmpfiles.d
and RuntimeDirectory=...
definitions are not compatible. You should not have both turned on at the same time.– Alexis Wilke
Oct 26 '18 at 8:02
Your Option 2 would have worked. However, the
tmpfiles.d
and RuntimeDirectory=...
definitions are not compatible. You should not have both turned on at the same time.– Alexis Wilke
Oct 26 '18 at 8:02
add a comment |
2 Answers
2
active
oldest
votes
I added in PermissionsStartOnly=True
and set a runtime folder per service, as suggested. I also added 0
to the start of the folder mode.
[Unit]
Description=gunicorn_django daemon
After=network.target
[Service]
PermissionsStartOnly=True
User=gunicorn
Group=www-data
RuntimeDirectory=gunicorn_django
RuntimeDirectoryMode=0775
PIDFile=/run/gunicorn_django/django_test_pid
WorkingDirectory=/vagrant/webapps/django_venv/django_test
ExecStart=/vagrant/webapps/django_venv/bin/gunicorn --pid /run/gunicorn_django/django_test_pid --workers 3 --bind unix:/run/gunicorn_django/django_test_socket django_test.wsgi --error-logfile /var/log/gunicorn/django_test_error.log
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
WantedBy=multi-user.target
It's now creating a folder with the correct permissions.
drwxrwxrw- 2 gunicorn www-data 40 Mar 30 07:11 gunicorn_django/
Thanks @quixotic and @mark-stosberg
add a comment |
My problem was that I had two services using same RuntimeDirectory
(isc-dhcp-server
and isc-dhcp-server6
), but I configured only one to work. So when the second one died, its runtime directory got removed, making it a problem for the first service.
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%2f354583%2fhow-to-automatically-create-a-runtime-folder-with-a-systemd-service-or-tmpfiles%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I added in PermissionsStartOnly=True
and set a runtime folder per service, as suggested. I also added 0
to the start of the folder mode.
[Unit]
Description=gunicorn_django daemon
After=network.target
[Service]
PermissionsStartOnly=True
User=gunicorn
Group=www-data
RuntimeDirectory=gunicorn_django
RuntimeDirectoryMode=0775
PIDFile=/run/gunicorn_django/django_test_pid
WorkingDirectory=/vagrant/webapps/django_venv/django_test
ExecStart=/vagrant/webapps/django_venv/bin/gunicorn --pid /run/gunicorn_django/django_test_pid --workers 3 --bind unix:/run/gunicorn_django/django_test_socket django_test.wsgi --error-logfile /var/log/gunicorn/django_test_error.log
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
WantedBy=multi-user.target
It's now creating a folder with the correct permissions.
drwxrwxrw- 2 gunicorn www-data 40 Mar 30 07:11 gunicorn_django/
Thanks @quixotic and @mark-stosberg
add a comment |
I added in PermissionsStartOnly=True
and set a runtime folder per service, as suggested. I also added 0
to the start of the folder mode.
[Unit]
Description=gunicorn_django daemon
After=network.target
[Service]
PermissionsStartOnly=True
User=gunicorn
Group=www-data
RuntimeDirectory=gunicorn_django
RuntimeDirectoryMode=0775
PIDFile=/run/gunicorn_django/django_test_pid
WorkingDirectory=/vagrant/webapps/django_venv/django_test
ExecStart=/vagrant/webapps/django_venv/bin/gunicorn --pid /run/gunicorn_django/django_test_pid --workers 3 --bind unix:/run/gunicorn_django/django_test_socket django_test.wsgi --error-logfile /var/log/gunicorn/django_test_error.log
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
WantedBy=multi-user.target
It's now creating a folder with the correct permissions.
drwxrwxrw- 2 gunicorn www-data 40 Mar 30 07:11 gunicorn_django/
Thanks @quixotic and @mark-stosberg
add a comment |
I added in PermissionsStartOnly=True
and set a runtime folder per service, as suggested. I also added 0
to the start of the folder mode.
[Unit]
Description=gunicorn_django daemon
After=network.target
[Service]
PermissionsStartOnly=True
User=gunicorn
Group=www-data
RuntimeDirectory=gunicorn_django
RuntimeDirectoryMode=0775
PIDFile=/run/gunicorn_django/django_test_pid
WorkingDirectory=/vagrant/webapps/django_venv/django_test
ExecStart=/vagrant/webapps/django_venv/bin/gunicorn --pid /run/gunicorn_django/django_test_pid --workers 3 --bind unix:/run/gunicorn_django/django_test_socket django_test.wsgi --error-logfile /var/log/gunicorn/django_test_error.log
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
WantedBy=multi-user.target
It's now creating a folder with the correct permissions.
drwxrwxrw- 2 gunicorn www-data 40 Mar 30 07:11 gunicorn_django/
Thanks @quixotic and @mark-stosberg
I added in PermissionsStartOnly=True
and set a runtime folder per service, as suggested. I also added 0
to the start of the folder mode.
[Unit]
Description=gunicorn_django daemon
After=network.target
[Service]
PermissionsStartOnly=True
User=gunicorn
Group=www-data
RuntimeDirectory=gunicorn_django
RuntimeDirectoryMode=0775
PIDFile=/run/gunicorn_django/django_test_pid
WorkingDirectory=/vagrant/webapps/django_venv/django_test
ExecStart=/vagrant/webapps/django_venv/bin/gunicorn --pid /run/gunicorn_django/django_test_pid --workers 3 --bind unix:/run/gunicorn_django/django_test_socket django_test.wsgi --error-logfile /var/log/gunicorn/django_test_error.log
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
WantedBy=multi-user.target
It's now creating a folder with the correct permissions.
drwxrwxrw- 2 gunicorn www-data 40 Mar 30 07:11 gunicorn_django/
Thanks @quixotic and @mark-stosberg
edited Mar 30 '17 at 9:54
answered Mar 30 '17 at 7:16
geonautgeonaut
1011 silver badge7 bronze badges
1011 silver badge7 bronze badges
add a comment |
add a comment |
My problem was that I had two services using same RuntimeDirectory
(isc-dhcp-server
and isc-dhcp-server6
), but I configured only one to work. So when the second one died, its runtime directory got removed, making it a problem for the first service.
add a comment |
My problem was that I had two services using same RuntimeDirectory
(isc-dhcp-server
and isc-dhcp-server6
), but I configured only one to work. So when the second one died, its runtime directory got removed, making it a problem for the first service.
add a comment |
My problem was that I had two services using same RuntimeDirectory
(isc-dhcp-server
and isc-dhcp-server6
), but I configured only one to work. So when the second one died, its runtime directory got removed, making it a problem for the first service.
My problem was that I had two services using same RuntimeDirectory
(isc-dhcp-server
and isc-dhcp-server6
), but I configured only one to work. So when the second one died, its runtime directory got removed, making it a problem for the first service.
answered 45 mins ago
MitarMitar
2482 silver badges6 bronze badges
2482 silver badges6 bronze badges
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%2f354583%2fhow-to-automatically-create-a-runtime-folder-with-a-systemd-service-or-tmpfiles%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
1
It's something to do with group permissions in the /run/ folder. I can create a 0755 folder with the group as
www-data
, but I need the folder to be group writeable, so both the Nginx user and the Gunicorn user can access the socket file. In order to do that, I need sudo-level permissions. For some reason,sudo systemctl... etc
isn't passing the sudo permissions to the service.– geonaut
Mar 29 '17 at 15:47
2
i'll bet it's trying to create the directory with the uid from
User=
and failing. try addingPermissionsStartOnly=true
. see unix.stackexchange.com/a/207493/222377– quixotic
Mar 29 '17 at 17:07
hmm. actually i'll bet it's failing because the runtime directory is made but isn't
/run/gunicorn
. it's probably$XDG_RUNTIME_DIR/gunicorn
which might resolve to/run/user/$UID/gunicorn
for thegunicorn
user UID. (same question, next answer.)– quixotic
Mar 29 '17 at 17:16
Are you trying to use the same directory for multiple Gunicorn instances? You could be running into this related issue>
– Mark Stosberg
Mar 29 '17 at 17:22
Your Option 2 would have worked. However, the
tmpfiles.d
andRuntimeDirectory=...
definitions are not compatible. You should not have both turned on at the same time.– Alexis Wilke
Oct 26 '18 at 8:02