Hi Yvan,
Yvan Taviaud wrote:
> > The primary problem with this is: How should it find the according
> > init.d script or .service file if not via the package's file list?
>
> I think that if the process isn't packaged, it was installed by the user,
> hence he can find out by himself how to restart it.
Yes, I think that's a good compromise.
> I've spent one hour on a fix for 0.68, I'm not a Python programmer, but
> that will do what I wished it would. The idea is to list all programs in
> programsNotFoundInPackages, then remove each program found in a package.
> When done, list all remaining programsNotFoundInPackages, add these to a
> fake package (nonPackagedName). At the end, show all these packages in a
> «Non-packaged processes:» output.
>
> Can someone take a look at it?
Thanks for the patch. Since Debian's freeze for the upcoming stable
released named Stretch is imminent, we won't apply the patch in the
next few months, but will have closer look at it after Debian's
Stretch release (which hopefully happens this summer).
For later reference, attached are your changes against 0.68 again with
as a context diff. This makes it easier to apply later, if other code
has and hence line numbers changed in the meanwhile, e.g. by bug fixes
which might be necessary for the Stretch release. Additionally I
reversed the patch. (Your patch removed all these lines instead of
adding them.)
Regards, Axel
--
,''`. | Axel Beckert <[email protected]>, http://people.debian.org/~abe/
: :' : | Debian Developer, ftp.ch.debian.org Admin
`. `' | 4096R: 2517 B724 C5F6 CA99 5329 6E61 2FF9 CD59 6126 16B5
`- | 1024D: F067 EA27 26B9 C3FC 1486 202E C09E 1D89 9593 0EDE
diff --git a/checkrestart b/checkrestart
index b1ce36b..967395a 100755
--- a/checkrestart
+++ b/checkrestart
@@ -155,9 +155,11 @@ def main():
sys.exit(0)
programs = {}
+ programsNotFoundInPackages = {}
for process in toRestart:
programs.setdefault(process.program, [])
programs[process.program].append(process)
+ programsNotFoundInPackages.setdefault(process.program, False)
if len(programs) == 1:
print("(%d distinct program)" % len(programs))
@@ -172,6 +174,7 @@ def main():
packages = {}
diverted = None
+ nonPackagedName = 'fake-package-for-non-packaged-processes'
dpkgQuery = ["dpkg-query", "--search"] + list(programs.keys())
if verbose:
@@ -207,6 +210,7 @@ def main():
packages.setdefault(packagename,Package(packagename))
try:
packages[packagename].processes.extend(programs[program])
+ programsNotFoundInPackages.pop(program)
if verbose:
print("[DEBUG] Found package %s for program %s" % (packagename, program))
except KeyError:
@@ -216,6 +220,12 @@ def main():
# Close the pipe
dpkgProc.stdout.close()
+ for program in programsNotFoundInPackages:
+ packages.setdefault(nonPackagedName,Package(nonPackagedName))
+ packages[nonPackagedName].processes.extend(programs[program])
+ if verbose:
+ print("[DEBUG] Program not found in any package, attaching to non-packaged fake package: %s" % (program))
+
# Remove the ignored packages from the list of packages
if ignorelist:
for i in ignorelist:
@@ -235,6 +245,9 @@ def main():
sys.exit(0)
for package in list(packages.values()):
+ if (package.name == nonPackagedName):
+ continue
+
dpkgQuery = ["dpkg-query", "--listfiles", package.name]
if verbose:
print("[DEBUG] Running: %s" % ' '.join(dpkgQuery))
@@ -312,7 +325,11 @@ def main():
# TODO - consider putting this in a --verbose option
print("These processes (%d) do not seem to have an associated init script to restart them:" %len(nonrestartable))
for package in nonrestartable:
+ if (package.name == nonPackagedName):
+ print('Non-packaged processes:')
+ else:
print(package.name + ':')
+
for process in package.processes:
print("\t%s\t%s" % (process.pid,process.program))
@@ -394,6 +411,7 @@ def procfilescheck(blacklist = None, excludepidlist = None):
process = processes.setdefault(pid,Process(int(pid)))
# print pid + ': ' + ', '.join(foundfiles)
process.files = foundfiles
+ process.found = False
toRestart = [process for process in list(processes.values()) if process.needsRestart(blacklist)]
return toRestart