Skip to content

Instantly share code, notes, and snippets.

@yinyin
Created December 16, 2012 17:18
Show Gist options
  • Save yinyin/4309765 to your computer and use it in GitHub Desktop.
Save yinyin/4309765 to your computer and use it in GitHub Desktop.
argument parsing of daemonize.pl
if($opt =~ /^--pid=(.+)$/)
{ $PID = $1; $PID =~ s/\s+$//; }
elsif($opt =~/^--(working-dir|wd)=(.+)$/)
{ $WORKDIR = $2; $WORKDIR =~ s/\s+$//; }
elsif($opt =~/^--(log|terminal-log)=(.+)$/)
{ $TRMLOG = $2; $TRMLOG =~ s/\s+$//; }
elsif($opt =~/^--send-int-before-term=([0-9]+)$/)
{ $SEND_INT_BEFORE_TERM = int($1); }
elsif( ($opt eq '-v') or ($opt eq '--verbose') )
{ $VERBOSE = 1; }
elsif($opt eq '--')
{ $readopt = 0; }
elsif($opt eq 'start')
{ $operation_mode = 'start'; }
elsif($opt eq 'stop')
{ $operation_mode = 'stop'; }
elsif( ($opt eq 'check') or ($opt eq 'status') )
{ $operation_mode = 'check'; }
elsif($opt eq 'startstart')
{ $operation_mode = 'startstart'; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment