Skip to content

Commit

Permalink
write pid file if requested
Browse files Browse the repository at this point in the history
  • Loading branch information
mojombo committed Jul 8, 2008
1 parent 2ff8cba commit e668306
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
*.beam *.beam
*.log *.log
*.pid
6 changes: 6 additions & 0 deletions bin/egitd
Expand Up @@ -23,6 +23,10 @@ OptionParser.new do |opts|
opts.on("-l LOG", "Log file") do |x| opts.on("-l LOG", "Log file") do |x|
options[:log] = x options[:log] = x
end end

opts.on("-P PIDFILE", "Pid file") do |x|
options[:pidfile] = x
end


opts.on("-d", "Run as a daemon") do opts.on("-d", "Run as a daemon") do
options[:daemon] = true options[:daemon] = true
Expand All @@ -31,9 +35,11 @@ end.parse!


detached = options[:daemon] ? '-detached' : '' detached = options[:daemon] ? '-detached' : ''
log = options[:log] ? "-egitd log '\"#{options[:log]}\"'" : '' log = options[:log] ? "-egitd log '\"#{options[:log]}\"'" : ''
pidfile = options[:pidfile] ? "-egitd pidfile '\"#{options[:pidfile]}\"'" : ''


cmd = %Q{erl -boot start_sasl \ cmd = %Q{erl -boot start_sasl \
#{detached} \ #{detached} \
#{pidfile} \
+Bc \ +Bc \
+K true \ +K true \
-smp enable \ -smp enable \
Expand Down
7 changes: 7 additions & 0 deletions elibs/egitd_sup.erl
Expand Up @@ -15,6 +15,13 @@ start_link(Args) ->
supervisor:start_link({local, ?MODULE}, ?MODULE, Args). supervisor:start_link({local, ?MODULE}, ?MODULE, Args).


init([]) -> init([]) ->
case application:get_env(pidfile) of
{ok, Location} ->
Pid = os:getpid(),
ok = file:write_file(Location, list_to_binary(Pid));
undefined -> ok
end,

{ok, {{one_for_one, 100, 300}, {ok, {{one_for_one, 100, 300},
[{server, [{server,
{server, start_link, []}, {server, start_link, []},
Expand Down

0 comments on commit e668306

Please sign in to comment.