-
Notifications
You must be signed in to change notification settings - Fork 206
Bug 1409957 - Create polling daemon to query Phabricator for recent transcations and update bug data according to revision changes #264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+1,350
−61
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
60bd095
WIP: Bug 1409957 - Create polling daemon to query Phabricator for rec…
dklawren e969e03
Remove some boilerplate using Moo
dylanwh d2662bc
WIP: Bug 1409957 - Create polling daemon to query Phabricator for rec…
dklawren 71d177d
Cleanups and refactoring from last commit.
dklawren d7f344c
Removed get_feed_transactions from Util.pm
dklawren 67ac4de
Fixed merge issue with PhabBugz/lib/Util.pm
dklawren c6ba403
- Added Project.pm for wrapping phabricator projects. Can be used for
dklawren f0837dd
Merge branch 'phabbugz-feed' of https://github.com/mozilla-bteam/bmo …
dklawren 5c7ff11
- Support for obsoleting attachments
dklawren 11334e2
- Use get_phab_bmo_ids instead of get_members_by_phid
dklawren 62af289
- Fixed some typos in Revision.pm
dklawren 81c2de1
catch exceptions that bubble up to main loop (#269)
dylanwh ea49d29
- Fixed some of the review comments by Dylan such as transaction orde…
dklawren ce0a219
- Changed to use feed.query_id instead of feed.query_epoch.
dklawren 7ff004a
add some validation / type checking
dylanwh e4a3aed
Merge branch 'master' into phabbugz-feed
dylanwh a4aa6b9
Merge branch 'master' into phabbugz-feed
dylanwh 4d9cdcf
Merge branch 'master' into phabbugz-feed
dylanwh 74d433d
Merge branch 'master' into phabbugz-feed
dylanwh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #!/usr/bin/perl | ||
|
|
||
| # This Source Code Form is subject to the terms of the Mozilla Public | ||
| # License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| # file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| # | ||
| # This Source Code Form is "Incompatible With Secondary Licenses", as | ||
| # defined by the Mozilla Public License, v. 2.0. | ||
|
|
||
| use 5.10.1; | ||
| use strict; | ||
| use warnings; | ||
|
|
||
| use lib qw(. lib local/lib/perl5); | ||
|
|
||
| BEGIN { | ||
| use Bugzilla; | ||
| Bugzilla->extensions; | ||
| } | ||
|
|
||
| use Bugzilla::Extension::PhabBugz::Daemon; | ||
| Bugzilla::Extension::PhabBugz::Daemon->start(); | ||
|
|
||
| =head1 NAME | ||
|
|
||
| phabbugz_feed.pl - Query Phabricator for interesting changes and update bugs related to revisions. | ||
|
|
||
| =head1 SYNOPSIS | ||
|
|
||
| phabbugz_feed.pl [OPTIONS] COMMAND | ||
|
|
||
| OPTIONS: | ||
| -f Run in the foreground (don't detach) | ||
| -d Output a lot of debugging information | ||
| -p file Specify the file where phabbugz_feed.pl should store its current | ||
| process id. Defaults to F<data/phabbugz_feed.pl.pid>. | ||
| -n name What should this process call itself in the system log? | ||
| Defaults to the full path you used to invoke the script. | ||
|
|
||
| COMMANDS: | ||
| start Starts a new phabbugz_feed daemon if there isn't one running already | ||
| stop Stops a running phabbugz_feed daemon | ||
| restart Stops a running phabbugz_feed if one is running, and then | ||
| starts a new one. | ||
| check Report the current status of the daemon. | ||
| install On some *nix systems, this automatically installs and | ||
| configures phabbugz_feed.pl as a system service so that it will | ||
| start every time the machine boots. | ||
| uninstall Removes the system service for phabbugz_feed.pl. | ||
| help Display this usage info |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| # This Source Code Form is subject to the terms of the Mozilla Public | ||
| # License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| # file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| # | ||
| # This Source Code Form is "Incompatible With Secondary Licenses", as | ||
| # defined by the Mozilla Public License, v. 2.0. | ||
|
|
||
| package Bugzilla::Extension::PhabBugz::Daemon; | ||
|
|
||
| use 5.10.1; | ||
| use strict; | ||
| use warnings; | ||
|
|
||
| use Bugzilla::Constants; | ||
| use Bugzilla::Extension::PhabBugz::Feed; | ||
| use Bugzilla::Extension::PhabBugz::Logger; | ||
|
|
||
| use Carp qw(confess); | ||
| use Daemon::Generic; | ||
| use File::Basename; | ||
| use File::Spec; | ||
| use Pod::Usage; | ||
|
|
||
| sub start { | ||
| newdaemon(); | ||
| } | ||
|
|
||
| # | ||
| # daemon::generic config | ||
| # | ||
|
|
||
| sub gd_preconfig { | ||
| my $self = shift; | ||
| my $pidfile = $self->{gd_args}{pidfile}; | ||
| if (!$pidfile) { | ||
| $pidfile = File::Spec->catfile(bz_locations()->{datadir}, $self->{gd_progname} . ".pid"); | ||
| } | ||
| return (pidfile => $pidfile); | ||
| } | ||
|
|
||
| sub gd_getopt { | ||
| my $self = shift; | ||
| $self->SUPER::gd_getopt(); | ||
| if ($self->{gd_args}{progname}) { | ||
| $self->{gd_progname} = $self->{gd_args}{progname}; | ||
| } else { | ||
| $self->{gd_progname} = basename($0); | ||
| } | ||
| $self->{_original_zero} = $0; | ||
| $0 = $self->{gd_progname}; | ||
| } | ||
|
|
||
| sub gd_postconfig { | ||
| my $self = shift; | ||
| $0 = delete $self->{_original_zero}; | ||
| } | ||
|
|
||
| sub gd_more_opt { | ||
| my $self = shift; | ||
| return ( | ||
| 'pidfile=s' => \$self->{gd_args}{pidfile}, | ||
| 'n=s' => \$self->{gd_args}{progname}, | ||
| ); | ||
| } | ||
|
|
||
| sub gd_usage { | ||
| pod2usage({ -verbose => 0, -exitval => 'NOEXIT' }); | ||
| return 0; | ||
| }; | ||
|
|
||
| sub gd_redirect_output { | ||
| my $self = shift; | ||
|
|
||
| my $filename = File::Spec->catfile(bz_locations()->{datadir}, $self->{gd_progname} . ".log"); | ||
| open(STDERR, ">>", $filename) or (print "could not open stderr: $!" && exit(1)); | ||
| close(STDOUT); | ||
| open(STDOUT, ">&", STDERR) or die "redirect STDOUT -> STDERR: $!"; | ||
| $SIG{HUP} = sub { | ||
| close(STDERR); | ||
| open(STDERR, ">>", $filename) or (print "could not open stderr: $!" && exit(1)); | ||
| }; | ||
| } | ||
|
|
||
| sub gd_setup_signals { | ||
| my $self = shift; | ||
| $self->SUPER::gd_setup_signals(); | ||
| $SIG{TERM} = sub { $self->gd_quit_event(); } | ||
| } | ||
|
|
||
| sub gd_run { | ||
| my $self = shift; | ||
| $::SIG{__DIE__} = \&Carp::confess if $self->{debug}; | ||
| my $phabbugz = Bugzilla::Extension::PhabBugz::Feed->new(); | ||
| $phabbugz->is_daemon(1); | ||
| $phabbugz->logger( | ||
| Bugzilla::Extension::PhabBugz::Logger->new(debugging => $self->{debug})); | ||
| $phabbugz->start(); | ||
| } | ||
|
|
||
| 1; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather see you just call Bugzilla::Extensions::PhabBugz->get_instance() (remove the _). That way the person reading the code will know which file to look in.