Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

write pid file if requested

  • Loading branch information...
commit e66830619380f528d535e614a8e62bf1a2b18d2e 1 parent 2ff8cba
@mojombo authored
Showing with 14 additions and 0 deletions.
  1. +1 −0  .gitignore
  2. +6 −0 bin/egitd
  3. +7 −0 elibs/egitd_sup.erl
View
1  .gitignore
@@ -1,2 +1,3 @@
*.beam
*.log
+*.pid
View
6 bin/egitd
@@ -23,6 +23,10 @@ OptionParser.new do |opts|
opts.on("-l LOG", "Log file") do |x|
options[:log] = x
end
+
+ opts.on("-P PIDFILE", "Pid file") do |x|
+ options[:pidfile] = x
+ end
opts.on("-d", "Run as a daemon") do
options[:daemon] = true
@@ -31,9 +35,11 @@ end.parse!
detached = options[:daemon] ? '-detached' : ''
log = options[:log] ? "-egitd log '\"#{options[:log]}\"'" : ''
+pidfile = options[:pidfile] ? "-egitd pidfile '\"#{options[:pidfile]}\"'" : ''
cmd = %Q{erl -boot start_sasl \
#{detached} \
+ #{pidfile} \
+Bc \
+K true \
-smp enable \
View
7 elibs/egitd_sup.erl
@@ -15,6 +15,13 @@ start_link(Args) ->
supervisor:start_link({local, ?MODULE}, ?MODULE, Args).
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},
[{server,
{server, start_link, []},
Please sign in to comment.
Something went wrong with that request. Please try again.