mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Write PID file, path is configurable in ejabberdctl.cfg (EJAB-1023)
SVN Revision: 2526
This commit is contained in:
parent
342ea2753c
commit
1b81a2e3d6
@ -3378,6 +3378,8 @@ all the environment variables and command line parameters.</P><P>The environment
|
|||||||
Path to the directory with binary system libraries.
|
Path to the directory with binary system libraries.
|
||||||
</DD><DT CLASS="dt-description"><B><TT>EJABBERD_DOC_PATH</TT></B></DT><DD CLASS="dd-description">
|
</DD><DT CLASS="dt-description"><B><TT>EJABBERD_DOC_PATH</TT></B></DT><DD CLASS="dd-description">
|
||||||
Path to the directory with ejabberd documentation.
|
Path to the directory with ejabberd documentation.
|
||||||
|
</DD><DT CLASS="dt-description"><B><TT>EJABBERD_PID_PATH</TT></B></DT><DD CLASS="dd-description">
|
||||||
|
Path to the PID file that ejabberd can create when started.
|
||||||
</DD><DT CLASS="dt-description"><B><TT>HOME</TT></B></DT><DD CLASS="dd-description">
|
</DD><DT CLASS="dt-description"><B><TT>HOME</TT></B></DT><DD CLASS="dd-description">
|
||||||
Path to the directory that is considered <TT>ejabberd</TT>’s home.
|
Path to the directory that is considered <TT>ejabberd</TT>’s home.
|
||||||
This path is used to read the file <TT>.erlang.cookie</TT>.
|
This path is used to read the file <TT>.erlang.cookie</TT>.
|
||||||
|
@ -4327,6 +4327,8 @@ The environment variables:
|
|||||||
Path to the directory with binary system libraries.
|
Path to the directory with binary system libraries.
|
||||||
\titem{EJABBERD\_DOC\_PATH}
|
\titem{EJABBERD\_DOC\_PATH}
|
||||||
Path to the directory with ejabberd documentation.
|
Path to the directory with ejabberd documentation.
|
||||||
|
\titem{EJABBERD\_PID\_PATH}
|
||||||
|
Path to the PID file that ejabberd can create when started.
|
||||||
\titem{HOME}
|
\titem{HOME}
|
||||||
Path to the directory that is considered \ejabberd{}'s home.
|
Path to the directory that is considered \ejabberd{}'s home.
|
||||||
This path is used to read the file \term{.erlang.cookie}.
|
This path is used to read the file \term{.erlang.cookie}.
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
-author('alexey@process-one.net').
|
-author('alexey@process-one.net').
|
||||||
|
|
||||||
-export([start/0, stop/0,
|
-export([start/0, stop/0,
|
||||||
|
get_pid_file/0,
|
||||||
get_so_path/0, get_bin_path/0]).
|
get_so_path/0, get_bin_path/0]).
|
||||||
|
|
||||||
start() ->
|
start() ->
|
||||||
@ -63,3 +64,14 @@ get_bin_path() ->
|
|||||||
Path ->
|
Path ->
|
||||||
Path
|
Path
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
%% @spec () -> false | string()
|
||||||
|
get_pid_file() ->
|
||||||
|
case os:getenv("EJABBERD_PID_PATH") of
|
||||||
|
false ->
|
||||||
|
false;
|
||||||
|
"" ->
|
||||||
|
false;
|
||||||
|
Path ->
|
||||||
|
Path
|
||||||
|
end.
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
|
|
||||||
start(normal, _Args) ->
|
start(normal, _Args) ->
|
||||||
ejabberd_loglevel:set(4),
|
ejabberd_loglevel:set(4),
|
||||||
|
write_pid_file(),
|
||||||
application:start(sasl),
|
application:start(sasl),
|
||||||
randoms:start(),
|
randoms:start(),
|
||||||
db_init(),
|
db_init(),
|
||||||
@ -81,6 +82,7 @@ prep_stop(State) ->
|
|||||||
%% All the processes were killed when this function is called
|
%% All the processes were killed when this function is called
|
||||||
stop(_State) ->
|
stop(_State) ->
|
||||||
?INFO_MSG("ejabberd ~s is stopped in the node ~p", [?VERSION, node()]),
|
?INFO_MSG("ejabberd ~s is stopped in the node ~p", [?VERSION, node()]),
|
||||||
|
delete_pid_file(),
|
||||||
ejabberd_debug:stop(),
|
ejabberd_debug:stop(),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
@ -194,3 +196,34 @@ add_windows_nameservers() ->
|
|||||||
IPTs = win32_dns:get_nameservers(),
|
IPTs = win32_dns:get_nameservers(),
|
||||||
?INFO_MSG("Adding machine's DNS IPs to Erlang system:~n~p", [IPTs]),
|
?INFO_MSG("Adding machine's DNS IPs to Erlang system:~n~p", [IPTs]),
|
||||||
lists:foreach(fun(IPT) -> inet_db:add_ns(IPT) end, IPTs).
|
lists:foreach(fun(IPT) -> inet_db:add_ns(IPT) end, IPTs).
|
||||||
|
|
||||||
|
|
||||||
|
%%%
|
||||||
|
%%% PID file
|
||||||
|
%%%
|
||||||
|
|
||||||
|
write_pid_file() ->
|
||||||
|
case ejabberd:get_pid_file() of
|
||||||
|
false ->
|
||||||
|
ok;
|
||||||
|
PidFilename ->
|
||||||
|
write_pid_file(os:getpid(), PidFilename)
|
||||||
|
end.
|
||||||
|
|
||||||
|
write_pid_file(Pid, PidFilename) ->
|
||||||
|
case file:open(PidFilename, [write]) of
|
||||||
|
{ok, Fd} ->
|
||||||
|
io:format(Fd, "~s~n", [Pid]),
|
||||||
|
file:close(Fd);
|
||||||
|
{error, Reason} ->
|
||||||
|
?ERROR_MSG("Cannot write PID file ~s~nReason: ~p", [PidFilename, Reason]),
|
||||||
|
throw({cannot_write_pid_file, PidFilename, Reason})
|
||||||
|
end.
|
||||||
|
|
||||||
|
delete_pid_file() ->
|
||||||
|
case ejabberd:get_pid_file() of
|
||||||
|
false ->
|
||||||
|
ok;
|
||||||
|
PidFilename ->
|
||||||
|
file:delete(PidFilename)
|
||||||
|
end.
|
||||||
|
@ -110,6 +110,18 @@
|
|||||||
#
|
#
|
||||||
#ERLANG_NODE=ejabberd
|
#ERLANG_NODE=ejabberd
|
||||||
|
|
||||||
|
#.
|
||||||
|
#' EJABBERD_PID_PATH: ejabberd PID file
|
||||||
|
#
|
||||||
|
# Indicate the full path to the ejabberd Process identifier (PID) file.
|
||||||
|
# If this variable is defined, ejabberd writes the PID file when starts,
|
||||||
|
# and deletes it when stops.
|
||||||
|
# Remember to create the directory and grant write permission to ejabberd.
|
||||||
|
#
|
||||||
|
# Default: don't write PID file
|
||||||
|
#
|
||||||
|
#EJABBERD_PID_PATH=/var/run/ejabberd/ejabberd.pid
|
||||||
|
|
||||||
#.
|
#.
|
||||||
#'
|
#'
|
||||||
# vim: foldmarker=#',#. foldmethod=marker:
|
# vim: foldmarker=#',#. foldmethod=marker:
|
||||||
|
@ -118,6 +118,7 @@ export EJABBERD_LOG_PATH
|
|||||||
export EJABBERD_SO_PATH
|
export EJABBERD_SO_PATH
|
||||||
export EJABBERD_BIN_PATH
|
export EJABBERD_BIN_PATH
|
||||||
export EJABBERD_DOC_PATH
|
export EJABBERD_DOC_PATH
|
||||||
|
export EJABBERD_PID_PATH
|
||||||
export ERL_CRASH_DUMP
|
export ERL_CRASH_DUMP
|
||||||
export ERL_INETRC
|
export ERL_INETRC
|
||||||
export ERL_MAX_PORTS
|
export ERL_MAX_PORTS
|
||||||
|
Loading…
Reference in New Issue
Block a user