Problem starting Gunicorn Web Service using Systemd
Clash Royale CLAN TAG#URR8PPP
I have a problem running a Gunicorn Web service using Systemd.
Here are the files I created in order to execute:
The shell script file (/home/ubuntu/mata.sh):
#!/usr/bin/env bash
cd /home/ubuntu/workspace/test-api
/home/ubuntu/workspace/mata_venv/bin/gunicorn --workers=4 app:app --bind 0.0.0.0:xxxx
Here's my .service file (/lib/systemd/system/mata.service):
[Unit]
Description=Test API Service
After=multi-user.target
Conflicts=getty@tty1.service
[Service]
User=ubuntu
Type=simple
ExecStart=/home/ubuntu/mata.sh
StandardInput=tty-force
[Install]
WantedBy=multi-user.target
Running the shell script on its own works well, but when running systemctl status mata.service
, I am getting the following message:
Started Test API Service
mata.service: Main process exited, code=exited, status=216/GROUP
mata.service: Unit entered failed state.
mata.service: Failed with result 'exit-code'.
Any idea?
systemd
|
show 1 more comment
I have a problem running a Gunicorn Web service using Systemd.
Here are the files I created in order to execute:
The shell script file (/home/ubuntu/mata.sh):
#!/usr/bin/env bash
cd /home/ubuntu/workspace/test-api
/home/ubuntu/workspace/mata_venv/bin/gunicorn --workers=4 app:app --bind 0.0.0.0:xxxx
Here's my .service file (/lib/systemd/system/mata.service):
[Unit]
Description=Test API Service
After=multi-user.target
Conflicts=getty@tty1.service
[Service]
User=ubuntu
Type=simple
ExecStart=/home/ubuntu/mata.sh
StandardInput=tty-force
[Install]
WantedBy=multi-user.target
Running the shell script on its own works well, but when running systemctl status mata.service
, I am getting the following message:
Started Test API Service
mata.service: Main process exited, code=exited, status=216/GROUP
mata.service: Unit entered failed state.
mata.service: Failed with result 'exit-code'.
Any idea?
systemd
The sequencing here is throwing me off a little bit; are you starting it manually and then runningsystemctl status...
? You are starting it with systemctl, right?
– Jeff Schaller
Feb 19 at 14:38
1
Possible duplicate of systemd - My custom service exits with status code 216/GROUP
– JdeBP
Feb 19 at 14:43
@JdeBP, I don't see that the user set aGroup=
definition here; is the implication thatUser=ubuntu
is failing because of that user's groups? (The other aspect of the duplicate answer relates to usingnobody
, and seems unrelated to me)
– Jeff Schaller
Feb 19 at 15:03
systemd exit code 216 indicates "Failed to determine or change group credentials."
– Jeff Schaller
Feb 19 at 15:07
@JeffSchaller Yep, I am trying to start it with systemctl start mata.service
– Pavel Zagalsky
Feb 19 at 15:33
|
show 1 more comment
I have a problem running a Gunicorn Web service using Systemd.
Here are the files I created in order to execute:
The shell script file (/home/ubuntu/mata.sh):
#!/usr/bin/env bash
cd /home/ubuntu/workspace/test-api
/home/ubuntu/workspace/mata_venv/bin/gunicorn --workers=4 app:app --bind 0.0.0.0:xxxx
Here's my .service file (/lib/systemd/system/mata.service):
[Unit]
Description=Test API Service
After=multi-user.target
Conflicts=getty@tty1.service
[Service]
User=ubuntu
Type=simple
ExecStart=/home/ubuntu/mata.sh
StandardInput=tty-force
[Install]
WantedBy=multi-user.target
Running the shell script on its own works well, but when running systemctl status mata.service
, I am getting the following message:
Started Test API Service
mata.service: Main process exited, code=exited, status=216/GROUP
mata.service: Unit entered failed state.
mata.service: Failed with result 'exit-code'.
Any idea?
systemd
I have a problem running a Gunicorn Web service using Systemd.
Here are the files I created in order to execute:
The shell script file (/home/ubuntu/mata.sh):
#!/usr/bin/env bash
cd /home/ubuntu/workspace/test-api
/home/ubuntu/workspace/mata_venv/bin/gunicorn --workers=4 app:app --bind 0.0.0.0:xxxx
Here's my .service file (/lib/systemd/system/mata.service):
[Unit]
Description=Test API Service
After=multi-user.target
Conflicts=getty@tty1.service
[Service]
User=ubuntu
Type=simple
ExecStart=/home/ubuntu/mata.sh
StandardInput=tty-force
[Install]
WantedBy=multi-user.target
Running the shell script on its own works well, but when running systemctl status mata.service
, I am getting the following message:
Started Test API Service
mata.service: Main process exited, code=exited, status=216/GROUP
mata.service: Unit entered failed state.
mata.service: Failed with result 'exit-code'.
Any idea?
systemd
systemd
edited Feb 19 at 15:05
Jeff Schaller
43.4k1160140
43.4k1160140
asked Feb 19 at 13:36
Pavel ZagalskyPavel Zagalsky
1165
1165
The sequencing here is throwing me off a little bit; are you starting it manually and then runningsystemctl status...
? You are starting it with systemctl, right?
– Jeff Schaller
Feb 19 at 14:38
1
Possible duplicate of systemd - My custom service exits with status code 216/GROUP
– JdeBP
Feb 19 at 14:43
@JdeBP, I don't see that the user set aGroup=
definition here; is the implication thatUser=ubuntu
is failing because of that user's groups? (The other aspect of the duplicate answer relates to usingnobody
, and seems unrelated to me)
– Jeff Schaller
Feb 19 at 15:03
systemd exit code 216 indicates "Failed to determine or change group credentials."
– Jeff Schaller
Feb 19 at 15:07
@JeffSchaller Yep, I am trying to start it with systemctl start mata.service
– Pavel Zagalsky
Feb 19 at 15:33
|
show 1 more comment
The sequencing here is throwing me off a little bit; are you starting it manually and then runningsystemctl status...
? You are starting it with systemctl, right?
– Jeff Schaller
Feb 19 at 14:38
1
Possible duplicate of systemd - My custom service exits with status code 216/GROUP
– JdeBP
Feb 19 at 14:43
@JdeBP, I don't see that the user set aGroup=
definition here; is the implication thatUser=ubuntu
is failing because of that user's groups? (The other aspect of the duplicate answer relates to usingnobody
, and seems unrelated to me)
– Jeff Schaller
Feb 19 at 15:03
systemd exit code 216 indicates "Failed to determine or change group credentials."
– Jeff Schaller
Feb 19 at 15:07
@JeffSchaller Yep, I am trying to start it with systemctl start mata.service
– Pavel Zagalsky
Feb 19 at 15:33
The sequencing here is throwing me off a little bit; are you starting it manually and then running
systemctl status...
? You are starting it with systemctl, right?– Jeff Schaller
Feb 19 at 14:38
The sequencing here is throwing me off a little bit; are you starting it manually and then running
systemctl status...
? You are starting it with systemctl, right?– Jeff Schaller
Feb 19 at 14:38
1
1
Possible duplicate of systemd - My custom service exits with status code 216/GROUP
– JdeBP
Feb 19 at 14:43
Possible duplicate of systemd - My custom service exits with status code 216/GROUP
– JdeBP
Feb 19 at 14:43
@JdeBP, I don't see that the user set a
Group=
definition here; is the implication that User=ubuntu
is failing because of that user's groups? (The other aspect of the duplicate answer relates to using nobody
, and seems unrelated to me)– Jeff Schaller
Feb 19 at 15:03
@JdeBP, I don't see that the user set a
Group=
definition here; is the implication that User=ubuntu
is failing because of that user's groups? (The other aspect of the duplicate answer relates to using nobody
, and seems unrelated to me)– Jeff Schaller
Feb 19 at 15:03
systemd exit code 216 indicates "Failed to determine or change group credentials."
– Jeff Schaller
Feb 19 at 15:07
systemd exit code 216 indicates "Failed to determine or change group credentials."
– Jeff Schaller
Feb 19 at 15:07
@JeffSchaller Yep, I am trying to start it with systemctl start mata.service
– Pavel Zagalsky
Feb 19 at 15:33
@JeffSchaller Yep, I am trying to start it with systemctl start mata.service
– Pavel Zagalsky
Feb 19 at 15:33
|
show 1 more comment
1 Answer
1
active
oldest
votes
You don't have a "Type=simple" service, you have a forking service, since it's not the "mata.sh" process that you care about, it's the "gunicorn" process.
For a Type=simple service, change the [Service]
section to:
[Service]
User=ubuntu
Type=simple
WorkingDirectory=/home/ubuntu/workspace/test-api
ExecStart=/home/ubuntu/workspace/mata_venv/bin/gunicorn --workers=4 app:app --bind 0.0.0.0:xxxx
StandardInput=tty-force
... where I imported the cd
command with a WorkingDirectory directive.
Or make it a Forking service with:
[Service]
User=ubuntu
Type=forking
ExecStart=/home/ubuntu/mata.sh
StandardInput=tty-force
You may prefer the Type=forking solution if, as it appears, the gunicorn process starts sub-processes (workers=4).
See also docs.gunicorn.org/en/stable/deploy.html which has a sample systemd service file.
– Jeff Schaller
Feb 19 at 13:48
Hmmmm, getting the same error.. Any other suggestions?
– Pavel Zagalsky
Feb 19 at 14:32
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%2f501590%2fproblem-starting-gunicorn-web-service-using-systemd%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You don't have a "Type=simple" service, you have a forking service, since it's not the "mata.sh" process that you care about, it's the "gunicorn" process.
For a Type=simple service, change the [Service]
section to:
[Service]
User=ubuntu
Type=simple
WorkingDirectory=/home/ubuntu/workspace/test-api
ExecStart=/home/ubuntu/workspace/mata_venv/bin/gunicorn --workers=4 app:app --bind 0.0.0.0:xxxx
StandardInput=tty-force
... where I imported the cd
command with a WorkingDirectory directive.
Or make it a Forking service with:
[Service]
User=ubuntu
Type=forking
ExecStart=/home/ubuntu/mata.sh
StandardInput=tty-force
You may prefer the Type=forking solution if, as it appears, the gunicorn process starts sub-processes (workers=4).
See also docs.gunicorn.org/en/stable/deploy.html which has a sample systemd service file.
– Jeff Schaller
Feb 19 at 13:48
Hmmmm, getting the same error.. Any other suggestions?
– Pavel Zagalsky
Feb 19 at 14:32
add a comment |
You don't have a "Type=simple" service, you have a forking service, since it's not the "mata.sh" process that you care about, it's the "gunicorn" process.
For a Type=simple service, change the [Service]
section to:
[Service]
User=ubuntu
Type=simple
WorkingDirectory=/home/ubuntu/workspace/test-api
ExecStart=/home/ubuntu/workspace/mata_venv/bin/gunicorn --workers=4 app:app --bind 0.0.0.0:xxxx
StandardInput=tty-force
... where I imported the cd
command with a WorkingDirectory directive.
Or make it a Forking service with:
[Service]
User=ubuntu
Type=forking
ExecStart=/home/ubuntu/mata.sh
StandardInput=tty-force
You may prefer the Type=forking solution if, as it appears, the gunicorn process starts sub-processes (workers=4).
See also docs.gunicorn.org/en/stable/deploy.html which has a sample systemd service file.
– Jeff Schaller
Feb 19 at 13:48
Hmmmm, getting the same error.. Any other suggestions?
– Pavel Zagalsky
Feb 19 at 14:32
add a comment |
You don't have a "Type=simple" service, you have a forking service, since it's not the "mata.sh" process that you care about, it's the "gunicorn" process.
For a Type=simple service, change the [Service]
section to:
[Service]
User=ubuntu
Type=simple
WorkingDirectory=/home/ubuntu/workspace/test-api
ExecStart=/home/ubuntu/workspace/mata_venv/bin/gunicorn --workers=4 app:app --bind 0.0.0.0:xxxx
StandardInput=tty-force
... where I imported the cd
command with a WorkingDirectory directive.
Or make it a Forking service with:
[Service]
User=ubuntu
Type=forking
ExecStart=/home/ubuntu/mata.sh
StandardInput=tty-force
You may prefer the Type=forking solution if, as it appears, the gunicorn process starts sub-processes (workers=4).
You don't have a "Type=simple" service, you have a forking service, since it's not the "mata.sh" process that you care about, it's the "gunicorn" process.
For a Type=simple service, change the [Service]
section to:
[Service]
User=ubuntu
Type=simple
WorkingDirectory=/home/ubuntu/workspace/test-api
ExecStart=/home/ubuntu/workspace/mata_venv/bin/gunicorn --workers=4 app:app --bind 0.0.0.0:xxxx
StandardInput=tty-force
... where I imported the cd
command with a WorkingDirectory directive.
Or make it a Forking service with:
[Service]
User=ubuntu
Type=forking
ExecStart=/home/ubuntu/mata.sh
StandardInput=tty-force
You may prefer the Type=forking solution if, as it appears, the gunicorn process starts sub-processes (workers=4).
answered Feb 19 at 13:48
Jeff SchallerJeff Schaller
43.4k1160140
43.4k1160140
See also docs.gunicorn.org/en/stable/deploy.html which has a sample systemd service file.
– Jeff Schaller
Feb 19 at 13:48
Hmmmm, getting the same error.. Any other suggestions?
– Pavel Zagalsky
Feb 19 at 14:32
add a comment |
See also docs.gunicorn.org/en/stable/deploy.html which has a sample systemd service file.
– Jeff Schaller
Feb 19 at 13:48
Hmmmm, getting the same error.. Any other suggestions?
– Pavel Zagalsky
Feb 19 at 14:32
See also docs.gunicorn.org/en/stable/deploy.html which has a sample systemd service file.
– Jeff Schaller
Feb 19 at 13:48
See also docs.gunicorn.org/en/stable/deploy.html which has a sample systemd service file.
– Jeff Schaller
Feb 19 at 13:48
Hmmmm, getting the same error.. Any other suggestions?
– Pavel Zagalsky
Feb 19 at 14:32
Hmmmm, getting the same error.. Any other suggestions?
– Pavel Zagalsky
Feb 19 at 14:32
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%2f501590%2fproblem-starting-gunicorn-web-service-using-systemd%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
The sequencing here is throwing me off a little bit; are you starting it manually and then running
systemctl status...
? You are starting it with systemctl, right?– Jeff Schaller
Feb 19 at 14:38
1
Possible duplicate of systemd - My custom service exits with status code 216/GROUP
– JdeBP
Feb 19 at 14:43
@JdeBP, I don't see that the user set a
Group=
definition here; is the implication thatUser=ubuntu
is failing because of that user's groups? (The other aspect of the duplicate answer relates to usingnobody
, and seems unrelated to me)– Jeff Schaller
Feb 19 at 15:03
systemd exit code 216 indicates "Failed to determine or change group credentials."
– Jeff Schaller
Feb 19 at 15:07
@JeffSchaller Yep, I am trying to start it with systemctl start mata.service
– Pavel Zagalsky
Feb 19 at 15:33