Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

write pid file if requested

  • Loading branch information...
commit e66830619380f528d535e614a8e62bf1a2b18d2e 1 parent 2ff8cba
Tom Preston-Werner mojombo authored

Showing 3 changed files with 14 additions and 0 deletions. Show diff stats Hide diff stats

  1. +1 0  .gitignore
  2. +6 0 bin/egitd
  3. +7 0 elibs/egitd_sup.erl
1  .gitignore
... ... @@ -1,2 +1,3 @@
1 1 *.beam
2 2 *.log
  3 +*.pid
6 bin/egitd
@@ -23,6 +23,10 @@ OptionParser.new do |opts|
23 23 opts.on("-l LOG", "Log file") do |x|
24 24 options[:log] = x
25 25 end
  26 +
  27 + opts.on("-P PIDFILE", "Pid file") do |x|
  28 + options[:pidfile] = x
  29 + end
26 30
27 31 opts.on("-d", "Run as a daemon") do
28 32 options[:daemon] = true
@@ -31,9 +35,11 @@ end.parse!
31 35
32 36 detached = options[:daemon] ? '-detached' : ''
33 37 log = options[:log] ? "-egitd log '\"#{options[:log]}\"'" : ''
  38 +pidfile = options[:pidfile] ? "-egitd pidfile '\"#{options[:pidfile]}\"'" : ''
34 39
35 40 cmd = %Q{erl -boot start_sasl \
36 41 #{detached} \
  42 + #{pidfile} \
37 43 +Bc \
38 44 +K true \
39 45 -smp enable \
7 elibs/egitd_sup.erl
@@ -15,6 +15,13 @@ start_link(Args) ->
15 15 supervisor:start_link({local, ?MODULE}, ?MODULE, Args).
16 16
17 17 init([]) ->
  18 + case application:get_env(pidfile) of
  19 + {ok, Location} ->
  20 + Pid = os:getpid(),
  21 + ok = file:write_file(Location, list_to_binary(Pid));
  22 + undefined -> ok
  23 + end,
  24 +
18 25 {ok, {{one_for_one, 100, 300},
19 26 [{server,
20 27 {server, start_link, []},

0 comments on commit e668306

Please sign in to comment.
Something went wrong with that request. Please try again.