-1

I'm learning gearman and found that there are two ways to start the gearman:

  • sudo gearmand -d

  • sudo service gearman-job-server start

What's the difference?

When to use each of them?

Thanks for any feedback!

尤川豪
  • 459
  • 5
  • 26
  • 1
    Without knowing what is in the `gearman-job-server` init script this cannot be answered. If you *have* that script then you should be able to answer this fairly easily yourself by looking at it. – Etan Reisner May 18 '16 at 01:33
  • Thanks! I think I will go check and try to understand what's in the script. – 尤川豪 May 18 '16 at 01:36

1 Answers1

1

Well this is not specific to gearmand but it applies to almost all linux daemons/services.

The program/service can be invoked through different ways. Directly from the terminal, through scripts in /etc and other means. I am assuming you know what sudo does.

# gearmand -d

You are invoking gearmand executable directly. The shell knows where the executable is, because the PATH is set. You may search its location by using "whereis gearmand" or finding it with find. This is the direct way of calling the application/service.

"daemon" is a background process. The "-d" argument to gearman starts it in daemon mode (in background).

Advantage/s:

  1. If you compile multiple version of the service on the same machine, in this case "gearman", you can invoke them individually without installing/reinstalling.
  2. Sometimes the installation doesn't work or the service might not support startup scripts etc.

Disadvantage/s:

  1. May not give a uniform output like standard scripts / commands.
  2. You may need to know the location of the file.

# service gearman-job-server start

calls the script service which usually looks into the directory "/etc/init.d". If you wish to find where service is searching for the services in your linux distribution, you can look it up.

Search the location of service script "whereis service" then open it in less by "less path_to_service" or directly by "whereis service | cut -d " " -f2 | xargs less" to see the service file.

The service script sort of standardizes the way scripts are called in linux these days.

$ service service_name start

service_name started

$ service service_name start

service_name already running

$ service service_name stop

service_name stopped.

$ service service_name stop

service_name not running.

This provides a uniform way of starting or stopping all services.

Say Fay
  • 81
  • 4