Merge pull request #214 from Plexical/write-pid-file

Writes an optional specified PID file on startup
main
Vincent Driessen 12 years ago
commit 83496fef32

@ -27,6 +27,8 @@ def parse_args():
parser.add_argument('--verbose', '-v', action='store_true', default=False, help='Show more output') parser.add_argument('--verbose', '-v', action='store_true', default=False, help='Show more output')
parser.add_argument('--quiet', '-q', action='store_true', default=False, help='Show less output') parser.add_argument('--quiet', '-q', action='store_true', default=False, help='Show less output')
parser.add_argument('--sentry-dsn', action='store', default=None, metavar='URL', help='Report exceptions to this Sentry DSN') parser.add_argument('--sentry-dsn', action='store', default=None, metavar='URL', help='Report exceptions to this Sentry DSN')
parser.add_argument('--pid', action='store', default=None,
help='Write the process ID number to a file at the specified path')
parser.add_argument('queues', nargs='*', help='The queues to listen on (default: \'default\')') parser.add_argument('queues', nargs='*', help='The queues to listen on (default: \'default\')')
return parser.parse_args() return parser.parse_args()
@ -65,6 +67,10 @@ def main():
args.sentry_dsn = settings.get('SENTRY_DSN', args.sentry_dsn = settings.get('SENTRY_DSN',
os.environ.get('SENTRY_DSN', None)) os.environ.get('SENTRY_DSN', None))
if args.pid:
with open(os.path.expanduser(args.pid), "w") as fp:
fp.write(str(os.getpid()))
setup_loghandlers_from_args(args) setup_loghandlers_from_args(args)
setup_redis(args) setup_redis(args)

Loading…
Cancel
Save