Start systemd service after specific service? [closed] - service

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I have a general question. How does one start a systemd unit *.service after a particular *.service has started successfully?
More specific question is, how do I start website.service only after mongodb.service has started? In other words website.service should depend on mongodb.service.

In the .service file under the [Unit] section:
[Unit]
Description=My Website
After=syslog.target network.target mongodb.service
The important part is the mongodb.service
The manpage describes it however due to formatting it's not as clear on first sight
systemd.unit - well formatted
systemd.unit - not so well formatted

After= dependency is only effective when service including After= and service included by After= are both scheduled to start as part of your boot up.
Ex:
a.service
[Unit]
After=b.service
This way, if both a.service and b.service are enabled, then systemd will order b.service after a.service.
If I am not misunderstanding, what you are asking is how to start b.service when a.service starts even though b.service is not enabled.
The directive for this is Wants= or Requires= under [Unit].
website.service
[Unit]
Wants=mongodb.service
After=mongodb.service
The difference between Wants= and Requires= is that with Requires=, a failure to start b.service will cause the startup of a.service to fail, whereas with Wants=, a.service will start even if b.service fails. This is explained in detail on the man page of .unit.

Related

Raspberry pi NTP working without conf file [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
On raspberry, I was looking at the NTP configuration file under /etc/systemd/timesyncd.conf. All lines are commented (by default) but when I run the timedatectl status command, I get:
...
Network time on : yes
NTP synchronized : yes
...
How NTP works without configuration in conf file ? Where are NTP server links ?
Raspberry pi 3 ; Raspbian 9.13 (stretch)
The NTP management of systemd is called systemd-timesyncd. On my Ubuntu system, the corresponding systemd service is /lib/systemd/system/systemd-timesyncd.service. Typically, when you don't have items activated in a configuration file, daemons use default values. Moreover, if you look at the comment in the configuration file, you will see that the commented items are actually default values:
Entries in this file show the compile time defaults.
You can change settings by editing this file.
Defaults can be restored by simply deleting this file.

vapor: Address already in use (errno: 98) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I deployed my vapor project to Ubuntu. And made the configuration of supervisor and Nginx.
When I invoke my server. first call is success but When I try second call I get 502 bad gateway error from browser. When I check error log, the error is
"Fatal error: Error raised at top level: bind(descriptor:ptr:bytes:) failed: Address already in use (errno: 98) : file /home/buildnode/jenkins/wo$"
If I kill the port(8080) process. And after, I try to connect again first try is success then get fail again.
What should I do to get rid of this error?
This might be caused by another process using that port.
I had the same issue and was able to solve it by listing all the processes on port :8080:
$ sudo lsof -i :8080
and then killing all of them one by one by typing:
$ kill {PID of the process}
After that, my app built again properly.
taken from here
I had the same issue. This worked for me:
$ kill -9 {PID of the process}
Hope this helps!

Is it possible to use distinct supervisor (config) for each user (directory) individually? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
Is it possible to use distinct supervisor configuration for each account on the server. So that every user can use supervisor with different specification on his account. I mean instead of using all the same config file on the server they using a local copy of the conf file and run it separately?
Okay I came across with an article by Peter Ojo in medium that in some way answered my question. It is actually about installing supervisor on a shared hosting but I guess it will do it.
What you need to do is use the — install-dir flag to install
supervisor in a custom location to which your user has full access.
You can use the bin directory in your subfolder, i.e.
/home/yoursiteuser/bin, or create it if it doesn’t already exist. Add
this directory to the PYTHONPATH environmental variable by running the
following command;
export PYTHONPATH=$PYTHONPATH:/home/yoursiteuser/bin
Now you can verify that you have your custom bin directory in the
PYTHONPATH environmental variable by typing
echo $PYTHONPATH
ACTUALLY INSTALLING SUPERVISOR
Now you can install Supervisor using the easy_install command like so
> easy_install — install-dir=/home/yoursiteuser/bin supervisor This
should successfully install Supervisor on your server. Yaay!
USING SUPERVISOR
To use supervisor, you first need to create a configuration file with
the sample configuration. You can do this by running the following
command:
echo_supervisord_conf > supervisord.conf This will create the
configuration file named supervisord.conf in the current directory.
Now you can run supervisor like so;
supervisord –c supervisord.conf The -c flag tells supervisor where to
find the configuration file, in this case it’s right there in the same
current directory.

how to install initctl on a centos-7 box [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
service autofs restart
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service autofs restart
/etc/init.d/autofs: line 54: initctl: command not found
I have looked up on the web and do not see any yum package that can install initctl. can you please help.
CentOS 7 comes with systemctl to manage service. You don't need to use initctl.
service autofs restart should point to systemctl restart autofs
You can check the status of this service with systemctl status autofs and post us the output if not able to restart.

How to supervise a webserver with daemontools? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
How should I script daemontools superviser?
I've started to use D. J. Bernsteins' daemontools to keep some processes running and is working fine. But now I need to monitor a couple of additional conditions on those processes and I've failed to find good info on how to do that.
My scenario is that I have some processes running for a web app (pharo smalltalk virtual machines) and they respond http, each one in their port (that's for the for loadbalance). I would like to somehow ping those to verify that they are not only running but responding to http requests. If they don't respond in a certain way to a request for more than 30s they should be treated as crashed and simply be restarted.
Is this even possible with daemontools? if so, how should I write this script and where should I place it? or where's the documentation on this?
The simplest solution is to create another daemontool task with a script that sleeps for 30 seconds and then tests for the presence of the service (using wget or curl for example). If the service doesn't respond timely you can restart the service (svc -t yourapp) and/or send a notification. The run-script of the new service could look as simple as this:
#!/bin/sh
sleep 30
if ! wget --quiet --timeout=5 --delete-after "http://yourapp.com/" ; then
svc -t /etc/service/yourapp
fi
I've also made good experience with tools like Munin. Again you need to provide a script that provides information about the state of your image. If you setup your images with a REST service you can even provide really interesting metrics such as active sessions, inactive session, gc parameters, memory consumption, database statistics, ... The tool then draws nice graphs over time and lets you specify boundaries to get notified when things behave badly.
To detect if the service is responsive, you can use curl (a perfect fit for HTTP and command-line/shell scripts)
curl --connect-timeout 10 http://8.8.8.8
curl: (28) connect() timed out!
and you can write more sophisticated things, like checking that the response is 200 (OK) etc.