systemd is hanging when I start or restart a service
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
1
down vote
favorite
I'm new to systemd after upgrading to 16.04 and I'm encountering a problem with starting and restarting services. When I run (for example)...
systemctl start djalbat.com
...it seems to work, however I don't get the prompt back, it just appears to hang. If I ctrl-c
to get the prompt back and then test whether the service has started, it appears to have done so. I wonder what there is in the configuration that would cause this to happen? Here it is:
[Unit]
Description=djalbat.com
[Service]
Type=forking
WorkingDirectory=/var/www/djalbat.com/
ExecStart=/usr/bin/node ./bin/main.js start 2>&1 >> /var/log/djalbat.com.log
[Install]
WantedBy=multi-user.target
Also, if someone could point out the need for the last WantedBy
directive, that would be appreciated.
systemd
add a comment |Â
up vote
1
down vote
favorite
I'm new to systemd after upgrading to 16.04 and I'm encountering a problem with starting and restarting services. When I run (for example)...
systemctl start djalbat.com
...it seems to work, however I don't get the prompt back, it just appears to hang. If I ctrl-c
to get the prompt back and then test whether the service has started, it appears to have done so. I wonder what there is in the configuration that would cause this to happen? Here it is:
[Unit]
Description=djalbat.com
[Service]
Type=forking
WorkingDirectory=/var/www/djalbat.com/
ExecStart=/usr/bin/node ./bin/main.js start 2>&1 >> /var/log/djalbat.com.log
[Install]
WantedBy=multi-user.target
Also, if someone could point out the need for the last WantedBy
directive, that would be appreciated.
systemd
It might be because the service is configured to fork but actually it does not fork. What happens when you execute the command fromExecStart
in a terminal? Does it put itself into the background? If not, useType=simple
.
â Thomas
Feb 10 at 13:45
Let me try that. I put in that directive, much like theWantedBy
directive, simply because I'd seen it so many times in sample configurations.
â James Smith
Feb 10 at 14:17
That worked, many thanks! If you have a moment, please make your comment into an answer. Then I can accept it, which might help others coming here. Thanks again!
â James Smith
Feb 10 at 14:20
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm new to systemd after upgrading to 16.04 and I'm encountering a problem with starting and restarting services. When I run (for example)...
systemctl start djalbat.com
...it seems to work, however I don't get the prompt back, it just appears to hang. If I ctrl-c
to get the prompt back and then test whether the service has started, it appears to have done so. I wonder what there is in the configuration that would cause this to happen? Here it is:
[Unit]
Description=djalbat.com
[Service]
Type=forking
WorkingDirectory=/var/www/djalbat.com/
ExecStart=/usr/bin/node ./bin/main.js start 2>&1 >> /var/log/djalbat.com.log
[Install]
WantedBy=multi-user.target
Also, if someone could point out the need for the last WantedBy
directive, that would be appreciated.
systemd
I'm new to systemd after upgrading to 16.04 and I'm encountering a problem with starting and restarting services. When I run (for example)...
systemctl start djalbat.com
...it seems to work, however I don't get the prompt back, it just appears to hang. If I ctrl-c
to get the prompt back and then test whether the service has started, it appears to have done so. I wonder what there is in the configuration that would cause this to happen? Here it is:
[Unit]
Description=djalbat.com
[Service]
Type=forking
WorkingDirectory=/var/www/djalbat.com/
ExecStart=/usr/bin/node ./bin/main.js start 2>&1 >> /var/log/djalbat.com.log
[Install]
WantedBy=multi-user.target
Also, if someone could point out the need for the last WantedBy
directive, that would be appreciated.
systemd
systemd
asked Feb 10 at 13:40
James Smith
16118
16118
It might be because the service is configured to fork but actually it does not fork. What happens when you execute the command fromExecStart
in a terminal? Does it put itself into the background? If not, useType=simple
.
â Thomas
Feb 10 at 13:45
Let me try that. I put in that directive, much like theWantedBy
directive, simply because I'd seen it so many times in sample configurations.
â James Smith
Feb 10 at 14:17
That worked, many thanks! If you have a moment, please make your comment into an answer. Then I can accept it, which might help others coming here. Thanks again!
â James Smith
Feb 10 at 14:20
add a comment |Â
It might be because the service is configured to fork but actually it does not fork. What happens when you execute the command fromExecStart
in a terminal? Does it put itself into the background? If not, useType=simple
.
â Thomas
Feb 10 at 13:45
Let me try that. I put in that directive, much like theWantedBy
directive, simply because I'd seen it so many times in sample configurations.
â James Smith
Feb 10 at 14:17
That worked, many thanks! If you have a moment, please make your comment into an answer. Then I can accept it, which might help others coming here. Thanks again!
â James Smith
Feb 10 at 14:20
It might be because the service is configured to fork but actually it does not fork. What happens when you execute the command from
ExecStart
in a terminal? Does it put itself into the background? If not, use Type=simple
.â Thomas
Feb 10 at 13:45
It might be because the service is configured to fork but actually it does not fork. What happens when you execute the command from
ExecStart
in a terminal? Does it put itself into the background? If not, use Type=simple
.â Thomas
Feb 10 at 13:45
Let me try that. I put in that directive, much like the
WantedBy
directive, simply because I'd seen it so many times in sample configurations.â James Smith
Feb 10 at 14:17
Let me try that. I put in that directive, much like the
WantedBy
directive, simply because I'd seen it so many times in sample configurations.â James Smith
Feb 10 at 14:17
That worked, many thanks! If you have a moment, please make your comment into an answer. Then I can accept it, which might help others coming here. Thanks again!
â James Smith
Feb 10 at 14:20
That worked, many thanks! If you have a moment, please make your comment into an answer. Then I can accept it, which might help others coming here. Thanks again!
â James Smith
Feb 10 at 14:20
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
So it turned out that the command that is executed with the ExecStart
configuration did not fork whereas the systemd
service was configured for a forking executable. This lead systemctl
to wait for the for of the executable leading to a not returning command line.
The correct configuration for an executable that does not fork is to use Type=simple
.
[Unit]
Description=djalbat.com
[Service]
Type=simple
WorkingDirectory=/var/www/djalbat.com/
ExecStart=/usr/bin/node ./bin/main.js start 2>&1 >> /var/log/djalbat.com.log
[Install]
WantedBy=multi-user.target
The WantedBy
is needed to connect this unit with a target, so this unit or service is started automatically when the appropriate target is reached and the service is enabled to start automatically with
systemctl enable djalbat
Don't forget to refresh systemd
after you have made changes to your service files with
systemctl daemon-reload
The perfect answer, thank you.
â James Smith
Feb 10 at 17:15
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
So it turned out that the command that is executed with the ExecStart
configuration did not fork whereas the systemd
service was configured for a forking executable. This lead systemctl
to wait for the for of the executable leading to a not returning command line.
The correct configuration for an executable that does not fork is to use Type=simple
.
[Unit]
Description=djalbat.com
[Service]
Type=simple
WorkingDirectory=/var/www/djalbat.com/
ExecStart=/usr/bin/node ./bin/main.js start 2>&1 >> /var/log/djalbat.com.log
[Install]
WantedBy=multi-user.target
The WantedBy
is needed to connect this unit with a target, so this unit or service is started automatically when the appropriate target is reached and the service is enabled to start automatically with
systemctl enable djalbat
Don't forget to refresh systemd
after you have made changes to your service files with
systemctl daemon-reload
The perfect answer, thank you.
â James Smith
Feb 10 at 17:15
add a comment |Â
up vote
3
down vote
accepted
So it turned out that the command that is executed with the ExecStart
configuration did not fork whereas the systemd
service was configured for a forking executable. This lead systemctl
to wait for the for of the executable leading to a not returning command line.
The correct configuration for an executable that does not fork is to use Type=simple
.
[Unit]
Description=djalbat.com
[Service]
Type=simple
WorkingDirectory=/var/www/djalbat.com/
ExecStart=/usr/bin/node ./bin/main.js start 2>&1 >> /var/log/djalbat.com.log
[Install]
WantedBy=multi-user.target
The WantedBy
is needed to connect this unit with a target, so this unit or service is started automatically when the appropriate target is reached and the service is enabled to start automatically with
systemctl enable djalbat
Don't forget to refresh systemd
after you have made changes to your service files with
systemctl daemon-reload
The perfect answer, thank you.
â James Smith
Feb 10 at 17:15
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
So it turned out that the command that is executed with the ExecStart
configuration did not fork whereas the systemd
service was configured for a forking executable. This lead systemctl
to wait for the for of the executable leading to a not returning command line.
The correct configuration for an executable that does not fork is to use Type=simple
.
[Unit]
Description=djalbat.com
[Service]
Type=simple
WorkingDirectory=/var/www/djalbat.com/
ExecStart=/usr/bin/node ./bin/main.js start 2>&1 >> /var/log/djalbat.com.log
[Install]
WantedBy=multi-user.target
The WantedBy
is needed to connect this unit with a target, so this unit or service is started automatically when the appropriate target is reached and the service is enabled to start automatically with
systemctl enable djalbat
Don't forget to refresh systemd
after you have made changes to your service files with
systemctl daemon-reload
So it turned out that the command that is executed with the ExecStart
configuration did not fork whereas the systemd
service was configured for a forking executable. This lead systemctl
to wait for the for of the executable leading to a not returning command line.
The correct configuration for an executable that does not fork is to use Type=simple
.
[Unit]
Description=djalbat.com
[Service]
Type=simple
WorkingDirectory=/var/www/djalbat.com/
ExecStart=/usr/bin/node ./bin/main.js start 2>&1 >> /var/log/djalbat.com.log
[Install]
WantedBy=multi-user.target
The WantedBy
is needed to connect this unit with a target, so this unit or service is started automatically when the appropriate target is reached and the service is enabled to start automatically with
systemctl enable djalbat
Don't forget to refresh systemd
after you have made changes to your service files with
systemctl daemon-reload
answered Feb 10 at 15:51
Thomas
3,29481325
3,29481325
The perfect answer, thank you.
â James Smith
Feb 10 at 17:15
add a comment |Â
The perfect answer, thank you.
â James Smith
Feb 10 at 17:15
The perfect answer, thank you.
â James Smith
Feb 10 at 17:15
The perfect answer, thank you.
â James Smith
Feb 10 at 17:15
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1004853%2fsystemd-is-hanging-when-i-start-or-restart-a-service%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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
It might be because the service is configured to fork but actually it does not fork. What happens when you execute the command from
ExecStart
in a terminal? Does it put itself into the background? If not, useType=simple
.â Thomas
Feb 10 at 13:45
Let me try that. I put in that directive, much like the
WantedBy
directive, simply because I'd seen it so many times in sample configurations.â James Smith
Feb 10 at 14:17
That worked, many thanks! If you have a moment, please make your comment into an answer. Then I can accept it, which might help others coming here. Thanks again!
â James Smith
Feb 10 at 14:20