Discussion:
orthanc-postgresql
Sébastien Jodogne
2015-03-02 11:16:06 UTC
Permalink
Hi,

It's me again :)

I have just created and committed a Debian package for the official plugin that replaces the default SQLite database of Orthanc, by a PostgreSQL back-end [1]. This package turns Orthanc into a scalable vendor neutral archive for DICOM images.

Could someone have a look at this package, possibly mentoring it?

Thanks again,
Sébastien-



[1] http://anonscm.debian.org/viewvc/debian-med/trunk/packages/orthanc-postgresql/trunk/debian/
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@chu.ulg.ac.be
Sébastien Jodogne
2015-03-02 11:36:55 UTC
Permalink
Post by Sébastien Jodogne
I have just created and committed a Debian package for the official
plugin that replaces the default SQLite database of Orthanc, by a
PostgreSQL back-end [1]. This package turns Orthanc into a scalable
vendor neutral archive for DICOM images.
I have just thought about a possible problem with this plugin. Indeed, using it makes the startup of the Orthanc service dependent on the startup of the PostgreSQL service: Orthanc will crash if it started after PostgreSQL.

It would therefore be logical to modify the "/etc/init.d/orthanc" file [1] by applying the patch attached to this mail. However, this dependency cannot be added inside the main "orthanc" package, as PostgreSQL is not a dependency of the default version of Orthanc (that internally uses SQLite).

Could someone tell me how this case could be handled? Should the "orthanc-postgresql" package patch "/etc/init.d/orthanc" from "postinst" and un-apply the patch from "postrm"?

Thanks,
Sébastien-


[1] http://anonscm.debian.org/viewvc/debian-med/trunk/packages/orthanc/trunk/debian/orthanc.init?view=markup
Karsten Hilbert
2015-03-02 12:37:51 UTC
Permalink
Post by Sébastien Jodogne
Post by Sébastien Jodogne
I have just created and committed a Debian package for the official
plugin that replaces the default SQLite database of Orthanc, by a
PostgreSQL back-end [1]. This package turns Orthanc into a scalable
vendor neutral archive for DICOM images.
I have just thought about a possible problem with this
plugin. Indeed, using it makes the startup of the Orthanc
Which to ensure has happened is the task of systemd and its
predecessors. (Note that, ATM, systemd is the default init
system and Orthanc should provide init information tailored
to that, but that's a nitpick as far as your questions go).
Post by Sébastien Jodogne
Orthanc will crash if it started after PostgreSQL.
(you probably mean that the other way round ?)

Orthanc should gracefully fail if it cannot connect to
PostgreSQL, rather than crash (but I cannot imagine you don't
already do it that way).
Post by Sébastien Jodogne
It would therefore be logical to modify the
"/etc/init.d/orthanc" file [1] by applying the patch attached
to this mail. However, this dependency cannot be added inside
the main "orthanc" package, as PostgreSQL is not a dependency
of the default version of Orthanc (that internally uses
SQLite).
Hm, hm, a conditional startup dependancy.

This

http://www.freedesktop.org/software/systemd/man/systemd.unit.html

sayeth

Note that while systemd offers a flexible dependency
system between units it is recommended to use this
functionality only sparingly and instead rely on
techniques such as bus-based or socket-based activation
which make dependencies implicit, resulting in a both
simpler and more flexible system.

Does this point in the right direction ?
Post by Sébastien Jodogne
Could someone tell me how this case could be handled?
Should the "orthanc-postgresql" package patch
"/etc/init.d/orthanc" from "postinst" and un-apply the patch
from "postrm"?
Again, Debian strictly recommends against modifying files of
other packages. However, this might be solved by a (really
small) package orthanc-sqlite which CONFLICTS: with
orthanc-postgresql, both of which providing orthanc-backend
and both providing /etc/init.d/orthanc.init as appropriate.

Orthanc itself would then depend on orthanc-backend (which is
satisfied by both -sqlite and -postgresql).

:-)

Karsten
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@hermes.hilbert.loc
Karsten Hilbert
2015-03-02 12:48:14 UTC
Permalink
Post by Sébastien Jodogne
I have just created and committed a Debian package for the
official plugin that replaces the default SQLite database of
Orthanc, by a PostgreSQL back-end [1].
Delightedly I have noted that PG can be used to store both of
index _and_ the actual DICOM instances (?).

If so, I'd be interested to know which way you chose to store
DICOM instances inside PG -- by means of BYTEA columns or as
large objects ?

http://www.postgresql.org/docs/9.4/static/datatype-binary.html

http://www.postgresql.org/docs/9.4/static/largeobjects.html

(that'll influence recommendations regarding
backup/restore/failover)

For what it is worth, GNUmed uses BYTEA (while being aware of
both its benefits and limitations).

Karsten
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@hermes.hilbert.loc
Sébastien Jodogne
2015-03-02 12:59:41 UTC
Permalink
Post by Karsten Hilbert
Delightedly I have noted that PG can be used to store both of
index _and_ the actual DICOM instances (?).
Yes, you're right: Enabling the "libOrthancPostgreSQLStorage.so" will store the DICOM instances into PostgreSQL (and not on the filesystem).
Post by Karsten Hilbert
If so, I'd be interested to know which way you chose to store
DICOM instances inside PG -- by means of BYTEA columns or as
large objects ?
http://www.postgresql.org/docs/9.4/static/datatype-binary.html
http://www.postgresql.org/docs/9.4/static/largeobjects.html
(that'll influence recommendations regarding
backup/restore/failover)
The plugin uses large objects.
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@chu.ulg.ac.be
Karsten Hilbert
2015-03-02 13:15:56 UTC
Permalink
Post by Sébastien Jodogne
Post by Karsten Hilbert
Delightedly I have noted that PG can be used to store both of
index _and_ the actual DICOM instances (?).
Yes, you're right: Enabling the "libOrthancPostgreSQLStorage.so" will store the DICOM instances into PostgreSQL (and not on the filesystem).
That makes it a lot easier to take consistent backups.
Post by Sébastien Jodogne
Post by Karsten Hilbert
If so, I'd be interested to know which way you chose to store
DICOM instances inside PG -- by means of BYTEA columns or as
large objects ?
http://www.postgresql.org/docs/9.4/static/datatype-binary.html
http://www.postgresql.org/docs/9.4/static/largeobjects.html
The plugin uses large objects.
OK, good. That way they can be up to 4 TB in size (as opposed
to 1 GB of BYTEA).

http://michael.otacoo.com/postgresql-2/playing-with-large-objects-in-postgres/

Karsten
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@hermes.hilbert.loc
Sébastien Jodogne
2015-03-02 13:11:05 UTC
Permalink
Post by Karsten Hilbert
Post by Sébastien Jodogne
Orthanc will crash if it started after PostgreSQL.
(you probably mean that the other way round ?)
Yes, of course :)
Post by Karsten Hilbert
Orthanc should gracefully fail if it cannot connect to
PostgreSQL, rather than crash (but I cannot imagine you don't
already do it that way).
Well, indeed, Orthanc does not "crash", it just "exits with an error code" :)
Post by Karsten Hilbert
Again, Debian strictly recommends against modifying files of
other packages. However, this might be solved by a (really
small) package orthanc-sqlite which CONFLICTS: with
orthanc-postgresql, both of which providing orthanc-backend
and both providing /etc/init.d/orthanc.init as appropriate.
Orthanc itself would then depend on orthanc-backend (which is
satisfied by both -sqlite and -postgresql).
OK, got it!

Andreas, if you don't mind, I will therefore modify the "orthanc" package in the following way:

- All the content of the current "orthanc" package (notably the main binary "/usr/sbin/Orthanc") will be moved to some new package "orthanc-backend",
- "orthanc" will only provide "/etc/init.d/orthanc",
- "orthanc" will depend on "orthanc-backend".

The newly added "orthanc-postgresql" package will:

- depend on "orthanc-backend",
- conflict on "orthanc", and
- provide an alternate version of "/etc/init.d/orthanc" with postgresql in Required-Start and Required-Stop.

Does this sound OK?

Thanks again for these explanations,
Sébastien-
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@chu.ulg.ac.be
Karsten Hilbert
2015-03-02 13:30:50 UTC
Permalink
Post by Sébastien Jodogne
Post by Karsten Hilbert
Again, Debian strictly recommends against modifying files of
other packages. However, this might be solved by a (really
small) package orthanc-sqlite which CONFLICTS: with
orthanc-postgresql, both of which providing orthanc-backend
and both providing /etc/init.d/orthanc.init as appropriate.
Orthanc itself would then depend on orthanc-backend (which is
satisfied by both -sqlite and -postgresql).
OK, got it!
- All the content of the current "orthanc" package (notably the main binary "/usr/sbin/Orthanc") will be moved to some new package "orthanc-backend",
- "orthanc" will only provide "/etc/init.d/orthanc",
- "orthanc" will depend on "orthanc-backend".
- depend on "orthanc-backend",
- conflict on "orthanc", and
- provide an alternate version of "/etc/init.d/orthanc" with postgresql in Required-Start and Required-Stop.
While, technically, this should work it does sound a bit
backwards to me.

I would provide the following packages:

orthanc
main binary and general infrastructure
all the non-backend stuff
orthanc-sqlite
nearly empty package (?)
only providing orthanc.init without postgresql
perhaps providing backup/restore scripts for sqlite DB ?
Conflicts: orthanc-postgresql
orthanc-postgresql
providing orthanc.init with postgresql
providing PG backend plugin
Conflicts: orthanc-sqlite

Package orthanc could either Depends: on "orthanc-sqlite |
orthanc-postgresql" in which case either of which would
satisfy the dependency. If either is pre-installed or
co-installed in this invocation of apt-get the other wouldn't
get installed. Both cannot be co-installed at the same time
due to the conflict. One _must_ be installed due to the
Depends.

Alternatively, both -sqlite and -postgresql could Provides: a
(virtual) package "orthanc-backend" which does not contain
anything and doesn't really exist either. Orthanc itself
would then only depend on orthanc-backend (and not both of
-sqlite and -postgresql explicitely). That way, it is a lot
easier to add another backend: Just upload orthanc-oracle
which also Provides: orthanc-backend ... The drawback is
that you cannot "force" a "preference" (which is possible by
the order of ORed alternatives in "orthanc-sqlite |
orthanc-postgresql".

Pick your poison ...

Karsten
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@hermes.hilbert.loc
Andreas Tille
2015-03-02 14:39:08 UTC
Permalink
Hi,

I couldn't have explained better than Karsten - so just ACK.

Kind regards

Andreas.
Post by Karsten Hilbert
Post by Sébastien Jodogne
Post by Karsten Hilbert
Again, Debian strictly recommends against modifying files of
other packages. However, this might be solved by a (really
small) package orthanc-sqlite which CONFLICTS: with
orthanc-postgresql, both of which providing orthanc-backend
and both providing /etc/init.d/orthanc.init as appropriate.
Orthanc itself would then depend on orthanc-backend (which is
satisfied by both -sqlite and -postgresql).
OK, got it!
- All the content of the current "orthanc" package (notably the main binary "/usr/sbin/Orthanc") will be moved to some new package "orthanc-backend",
- "orthanc" will only provide "/etc/init.d/orthanc",
- "orthanc" will depend on "orthanc-backend".
- depend on "orthanc-backend",
- conflict on "orthanc", and
- provide an alternate version of "/etc/init.d/orthanc" with postgresql in Required-Start and Required-Stop.
While, technically, this should work it does sound a bit
backwards to me.
orthanc
main binary and general infrastructure
all the non-backend stuff
orthanc-sqlite
nearly empty package (?)
only providing orthanc.init without postgresql
perhaps providing backup/restore scripts for sqlite DB ?
Conflicts: orthanc-postgresql
orthanc-postgresql
providing orthanc.init with postgresql
providing PG backend plugin
Conflicts: orthanc-sqlite
Package orthanc could either Depends: on "orthanc-sqlite |
orthanc-postgresql" in which case either of which would
satisfy the dependency. If either is pre-installed or
co-installed in this invocation of apt-get the other wouldn't
get installed. Both cannot be co-installed at the same time
due to the conflict. One _must_ be installed due to the
Depends.
Alternatively, both -sqlite and -postgresql could Provides: a
(virtual) package "orthanc-backend" which does not contain
anything and doesn't really exist either. Orthanc itself
would then only depend on orthanc-backend (and not both of
-sqlite and -postgresql explicitely). That way, it is a lot
easier to add another backend: Just upload orthanc-oracle
which also Provides: orthanc-backend ... The drawback is
that you cannot "force" a "preference" (which is possible by
the order of ORed alternatives in "orthanc-sqlite |
orthanc-postgresql".
Pick your poison ...
Karsten
--
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
--
--
http://fam-tille.de
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@an3as.eu
Sébastien Jodogne
2015-03-02 16:35:09 UTC
Permalink
Hi again,
Post by Sébastien Jodogne
orthanc
main binary and general infrastructure
all the non-backend stuff
orthanc-sqlite
nearly empty package (?)
only providing orthanc.init without postgresql
perhaps providing backup/restore scripts for sqlite DB ?
Conflicts: orthanc-postgresql
orthanc-postgresql
providing orthanc.init with postgresql
providing PG backend plugin
Conflicts: orthanc-sqlite
Package orthanc could either Depends: on "orthanc-sqlite |
orthanc-postgresql" in which case either of which would
satisfy the dependency. If either is pre-installed or
co-installed in this invocation of apt-get the other wouldn't
get installed. Both cannot be co-installed at the same time
due to the conflict. One _must_ be installed due to the
Depends.
Thanks! I will use this approach, as I think it is important to enforce a preference in favor of the default SQLite back-end.

Sébastien-
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@chu.ulg.ac.be
Sébastien Jodogne
2015-03-04 08:52:40 UTC
Permalink
Hi,
Post by Sébastien Jodogne
orthanc
main binary and general infrastructure
all the non-backend stuff
orthanc-sqlite
nearly empty package (?)
only providing orthanc.init without postgresql
perhaps providing backup/restore scripts for sqlite DB ?
Conflicts: orthanc-postgresql
orthanc-postgresql
providing orthanc.init with postgresql
providing PG backend plugin
Conflicts: orthanc-sqlite
Package orthanc could either Depends: on "orthanc-sqlite |
orthanc-postgresql" in which case either of which would
satisfy the dependency. If either is pre-installed or
co-installed in this invocation of apt-get the other wouldn't
get installed. Both cannot be co-installed at the same time
due to the conflict. One _must_ be installed due to the
Depends.
I have started the refactoring of the orthanc package according to this approach [1]. This is still work-in-progress, but I now face problem I am unable to fix by myself.

By moving orthanc.init into the newly created orthanc-sqlite package, I had to move "debian/orthanc.init" to "debian/orthanc-sqlite.init". In turn, after installation, this renames "/etc/init.d/orthanc.init" as "/etc/init.d/orthanc-sqlite.init". But, the Orthanc service should still be called "/etc/init.d/orthanc.init", as there is only one Orthanc back-end that can be active at a given time (cf. the Conflicts).

I have tried playing with "override_dh_installinit" [2] to force the "orthanc.init" name, but with no success.

Could someone give me a hint about how to achieve this?

TIA,
Sébastien-


[1] http://anonscm.debian.org/viewvc/debian-med?view=revision&revision=18901
[2] http://anonscm.debian.org/viewvc/debian-med/trunk/packages/orthanc/trunk/debian/rules?view=markup&pathrev=18901
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@chu.ulg.ac.be
Karsten Hilbert
2015-03-04 09:58:51 UTC
Permalink
Post by Sébastien Jodogne
By moving orthanc.init into the newly created
orthanc-sqlite package, I had to move "debian/orthanc.init"
to "debian/orthanc-sqlite.init". In turn, after
installation, this renames "/etc/init.d/orthanc.init" as
"/etc/init.d/orthanc-sqlite.init".
Whoa, really, why ?
Post by Sébastien Jodogne
But, the Orthanc service should still be called
"/etc/init.d/orthanc.init", as there is only one Orthanc
back-end that can be active at a given time (cf. the
Conflicts).
Unless someone knows how to override the renaming behaviour
this is an option:

https://wiki.debian.org/DebianAlternatives

After all, maybe this can be a solution to the underlying
problem (init with our without the PG dependancy) which does
away with the package split entirely ? Alternatives are
meant for applications but can work for other files just as
well.

Sorry to not bring this up earlier.

Karsten
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@hermes.hilbert.loc
Sébastien Jodogne
2015-03-04 11:02:01 UTC
Permalink
Hi Karsten,
Post by Karsten Hilbert
Post by Sébastien Jodogne
By moving orthanc.init into the newly created
orthanc-sqlite package, I had to move "debian/orthanc.init"
to "debian/orthanc-sqlite.init". In turn, after
installation, this renames "/etc/init.d/orthanc.init" as
"/etc/init.d/orthanc-sqlite.init".
Whoa, really, why ?
Because other Orthanc plugins (e.g. orthanc-webviewer) need to restart Orthanc after their installation, in order for Orthanc to load them...

Concretely, they would need to do either "/etc/init.d/orthanc-sqlite restart" or "/etc/init.d/orthanc-postgresql restart" in their postinst/postrm, depending on the installed back-end. I therefore feel that it is more simple for all these back-ends to use "/etc/init.d/orthanc", so that the plugin packages can be agnostic of the back-end.

But maybe I am totally wrong?

Sébastien-
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@chu.ulg.ac.be
Karsten Hilbert
2015-03-04 11:07:16 UTC
Permalink
Post by Sébastien Jodogne
Post by Karsten Hilbert
Post by Sébastien Jodogne
By moving orthanc.init into the newly created
orthanc-sqlite package, I had to move "debian/orthanc.init"
to "debian/orthanc-sqlite.init". In turn, after
installation, this renames "/etc/init.d/orthanc.init" as
"/etc/init.d/orthanc-sqlite.init".
Whoa, really, why ?
Because other Orthanc plugins (e.g. orthanc-webviewer) need to restart Orthanc after their installation, in order for Orthanc to load them...
Concretely, they would need to do either
"/etc/init.d/orthanc-sqlite restart" or
"/etc/init.d/orthanc-postgresql restart" in their
postinst/postrm, depending on the installed back-end. I
therefore feel that it is more simple for all these back-ends
to use "/etc/init.d/orthanc", so that the plugin packages can
be agnostic of the back-end.
Sure, that's quite clear. I was rather wondering what forced
you to
Post by Sébastien Jodogne
Post by Karsten Hilbert
Post by Sébastien Jodogne
move "debian/orthanc.init" to "debian/orthanc-sqlite.init"
? Is this Debian policy ? Did lintian tell you to do so ?
(if so this sounds like an override is needed on that)

Karsten
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@hermes.hilbert.loc
Sébastien Jodogne
2015-03-04 11:31:27 UTC
Permalink
Post by Karsten Hilbert
Sure, that's quite clear.
:)
Post by Karsten Hilbert
I was rather wondering what forced
you to
Post by Sébastien Jodogne
move "debian/orthanc.init" to "debian/orthanc-sqlite.init"
? Is this Debian policy ? Did lintian tell you to do so ?
(if so this sounds like an override is needed on that)
If I keep "debian/orthanc.init", the file is considered as a part of the "orthanc" package, but it should be part of "orthanc-sqlite".
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@chu.ulg.ac.be
Karsten Hilbert
2015-03-04 12:09:54 UTC
Permalink
Post by Sébastien Jodogne
Post by Karsten Hilbert
I was rather wondering what forced
you to
Post by Sébastien Jodogne
move "debian/orthanc.init" to "debian/orthanc-sqlite.init"
? Is this Debian policy ? Did lintian tell you to do so ?
(if so this sounds like an override is needed on that)
If I keep "debian/orthanc.init", the file is considered as a part of the "orthanc" package, but it should be part of "orthanc-sqlite".
I see. Is this because you are building several packages from
one source package ?

Probably, the Alternatives system is the way to go.

Karsten
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@hermes.hilbert.loc
Andreas Tille
2015-03-04 12:49:11 UTC
Permalink
Hi Sébastien,
Post by Sébastien Jodogne
Post by Karsten Hilbert
Post by Sébastien Jodogne
move "debian/orthanc.init" to "debian/orthanc-sqlite.init"
? Is this Debian policy ? Did lintian tell you to do so ?
(if so this sounds like an override is needed on that)
If I keep "debian/orthanc.init", the file is considered as a part of the "orthanc" package, but it should be part of "orthanc-sqlite".
I had only a very quick look on your conversation but I'm not
aware about the rule you are talking about and I'm aware of
at least two counter examples:

$ dpkg -S /etc/init.d/networking
ifupdown: /etc/init.d/networking
$ dpkg -S /etc/init.d/postgresql
postgresql-common: /etc/init.d/postgresql

Did you found any written rule which forces you to name the init script
the same as the package?

Kind regards

Andreas.
--
http://fam-tille.de
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@an3as.eu
Sébastien Jodogne
2015-03-04 14:31:56 UTC
Permalink
Post by Andreas Tille
Post by Sébastien Jodogne
move "debian/orthanc.init" to "debian/orthanc-sqlite.init"
I had only a very quick look on your conversation but I'm not
aware about the rule you are talking about and I'm aware of
$ dpkg -S /etc/init.d/networking
ifupdown: /etc/init.d/networking
$ dpkg -S /etc/init.d/postgresql
postgresql-common: /etc/init.d/postgresql
Did you found any written rule which forces you to name the init
script
the same as the package?
OK, got it working thanks to the postgresql-common counter example!

The problem was that I had to rename "debian/orthanc-sqlite.init" to "debian/orthanc-sqlite.orthanc.init", in addition to making the "override_dh_installinit" in debian/rules.

Thanks for your help,
Sébastien-


[1] https://sources.debian.net/src/postgresql-common/166/debian/rules/
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@chu.ulg.ac.be
Sébastien Jodogne
2015-03-05 20:07:14 UTC
Permalink
Post by Sébastien Jodogne
Post by Sébastien Jodogne
orthanc
main binary and general infrastructure
all the non-backend stuff
orthanc-sqlite
nearly empty package (?)
only providing orthanc.init without postgresql
perhaps providing backup/restore scripts for sqlite DB ?
Conflicts: orthanc-postgresql
orthanc-postgresql
providing orthanc.init with postgresql
providing PG backend plugin
Conflicts: orthanc-sqlite
Thanks! I will use this approach, as I think it is important to
enforce a preference in favor of the default SQLite back-end.
Well... I have just discovered the "Should-Start:" syntax in LSB init scripts: "It defines the facilities that if present should start before the service provided by the script. Nevertheless, the script can still start if the listed facilities are missing. This allows for weak dependencies which do not cause the service to fail if a facility is not available." [1]

Therefore, I feel that the following header is sufficient to prevent the Orthanc service from starting before PostgreSQL (which was my initial fear that led to the discussion about orthanc-sqlite):

### BEGIN INIT INFO
# Provides: orthanc
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Should-Start: postgresql
# Should-Stop: postgresql
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Orthanc init script
# Description: Orthanc, a lightweight, RESTful DICOM server
### END INIT INFO

As a consequence, I now think that there is no reason anymore to introduce the "orthanc-sqlite" package... this of course greatly simplifies the packaging.

Andreas, Karsten, please could you confirm that this approach is sound?

TIA,
Sébastien-


[1] https://wiki.debian.org/LSBInitScripts
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@chu.ulg.ac.be
Karsten Hilbert
2015-03-05 22:10:16 UTC
Permalink
Post by Sébastien Jodogne
Well... I have just discovered the "Should-Start:" syntax in LSB init scripts: "It defines the facilities that if present should start before the service provided by the script. Nevertheless, the script can still start if the listed facilities are missing. This allows for weak dependencies which do not cause the service to fail if a facility is not available." [1]
### BEGIN INIT INFO
# Provides: orthanc
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Should-Start: postgresql
# Should-Stop: postgresql
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Orthanc init script
# Description: Orthanc, a lightweight, RESTful DICOM server
### END INIT INFO
As a consequence, I now think that there is no reason anymore to introduce the "orthanc-sqlite" package... this of course greatly simplifies the packaging.
Andreas, Karsten, please could you confirm that this approach is sound?
It would likely work for making orthanc only weakly depend on
PG running. However, it would not guarantuee that PG is
running when orthanc is configured to use PG.

Would Orthanc still fail when configured for PG but PG not
running or would it (silently ?!) fall back to use sqlite ?

I think we may have to go back rethinking to properly solve
this:

1) orthanc can use sqlite or postgresql as backend
2) the sqlite backend is built-in (?) and is intended
to always just work
3) to use PG orthanc must be configured to do so
4) you want orthanc at startup to make sure PG is
running if and only if it is configured to use PG

- (2) requires orthanc to Depends: on sqlite
- (4) requires either
a) different init scripts, one with and one without postgresql
or
b) some sort of dependency on PostgreSQL when PostgreSQL is
needed such that Should-Start: PostgreSQL _will_ succeed

Both of a) and b) require a package orthanc-postgresql which
can Depends: on PostgreSQL. If there is another
orthanc-sqlite package (which depends on sqlite and
Conflicts: with orthanc-PG) you can provide strict startup
dependancies. If not (and the main orthanc package Depends:
on sqlite) you can make the orthanc-PG package Depends: on PG
just as well but you cannot provide a strict Required-Start
on PostgreSQL (you'd _have_ to use Should-Start). However,
since when the user installs orthanc-PG that will Depends: on
PG and thusly also install PG which makes sure that
Should-Start: PG _will_ succeed.

The only drawback I see is that it is then not at all easy to
provide further backends because one cannot distinguish
between several Should-Start requirements. IOW, when - for
other reasons - both PG and MySQL are installed starting up
Orthanc will start both databases despite only needing one of
them.

However, one might argue: either the unneeded-by-orthanc
database is already running (exactly because it was installed
for other reasons) or else it isn't needed, in which case one
might uninstall it which will make the unneeded start go away.

However, sometimes (due to other packages not being so nice)
one has to install infrastructure software due to Depends:
but then disable actually running said infrastructure because
that package can be configured to use something else (but
still Depends: on something).

Just my 2¢.

Karsten
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@hermes.hilbert.loc
Sébastien Jodogne
2015-03-06 06:44:41 UTC
Permalink
Once again, thanks for all your explanations!
Post by Karsten Hilbert
It would likely work for making orthanc only weakly depend on
PG running. However, it would not guarantuee that PG is
running when orthanc is configured to use PG.
I am unsure to understand the second part of this paragraph: Does "Should-Start" only mean that when the Orthanc service starts, PostgreSQL is guaranteed to start during the boot process, but not necessarily *before* Orthanc?

By contrast, does "Required-Start" means that the boot process will start Orthanc only when PostgreSQL is started?
Post by Karsten Hilbert
Would Orthanc still fail when configured for PG but PG not
running or would it (silently ?!) fall back to use sqlite ?
If Orthanc is configured for PG but PG is not started, Orthanc will stop and will *not* fallback to sqlite.

Another point of attention is the following: Orthanc-PG does not necessarily requires PG to be running on the localhost (the PG server could be elsewhere). BTW, "debian/control" currently only "Suggests" postgresql. Would not this argument vote for "Should-Start" instead of "Required-Start"?

To be fair, I am more and more confused between the pros&cons of the introduction of the "orthanc-sqlite" package... I really feel unable to take the best decision by myself. The "orthanc-postgresql" and "orthanc-sqlite" are now ready for release. I could easily revert to "orthanc-postgresql" alone.

Andreas, Karsten, would it be possible for you to take this decision in my place? I will just make the job afterward...

Thanks,
Sébastien-
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@chu.ulg.ac.be
Karsten Hilbert
2015-03-06 10:04:05 UTC
Permalink
Post by Sébastien Jodogne
Another point of attention is the following: Orthanc-PG
does not necessarily requires PG to be running on the
localhost (the PG server could be elsewhere).
Aaah, true enough, there you said it all: Not even the
presence of an orthanc-PG pacakge on a given machine means
that the user wants (or needs) to run PG on that machine.

There is no way to sensibly enforce

make sure PG is started before Orthanc if and only if
Orthanc is configured to connnect to PG _and_ connect to
a _local_ PG database

The only way to usefully communicate that state is ...
Post by Sébastien Jodogne
If Orthanc is configured for PG but PG is not started,
Orthanc will stop, will *not* fallback to sqlite [, ...]
... and will loudly and clearly complain:

you have configured Orthanc to connect to PG with
$PG_CONN_STRING but I cannot connect with those
parameters, here is what libpq had to say:
$LIBPQ_ERROR_MESSAGE (if any)

So, all in all the only useful purpose an orthanc-PG package
might serve is to Depends: on postgresql-*client* thereby
ensuring libpq is installed :-) thereby freeing the
orthanc(-core) package from that Depends:.

There could be another use: orthanc-pg could provide a
working PG plugin configuration to orthanc(-core) -- which
then only needs setting of connection parameters -- but that
would require you to first make Orthanc read a configuration
directory on startup (because -pg may not modify -core's
config file):

/etc/orthanc/conf.d/ (from -core)
/etc/orthanc/conf.d/orthanc.conf (from -core)
/etc/orthanc/conf.d/sqlite.conf (from -sqlite or from -core)
/etc/orthanc/conf.d/pg.conf (from -pg)

An alternative would be to invent an inclusion mechanism for
json such that orthanc.conf can say

\include_if_exists(sqlite.conf)
\include_if_exists(pg.conf)

or some such.

HOWEVER, given that postgresql-client really isn't that big:

Installed-Size: 74 (kilobytes)
Size: 51988 (bytes)
Installed-Size: 73
Size: 51714
Installed-Size: 65
Size: 42506

you might just do away with the whole gamut and have
orthanc(-core) just install everything (core and PG plugin)
and also Depends: on sqlite _and_ postgresql-client. It would
then provide a default configuration for sqlite and a
correct-but-inactive configuration for the PG plugin.

That is probably what I would suggest at this point.

Karsten
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@hermes.hilbert.loc
Karsten Hilbert
2015-03-06 10:21:28 UTC
Permalink
Post by Sébastien Jodogne
I am unsure to understand the second part of this
paragraph: Does "Should-Start" only mean that when the
Orthanc service starts, PostgreSQL is guaranteed to start
during the boot process
No. To my understanding it means that the boot process will
attempt to start PG but not require that to succeed.
Post by Sébastien Jodogne
, but not necessarily *before* Orthanc?
No, IF it is started then it WILL be before Orthanc.
Post by Sébastien Jodogne
By contrast, does "Required-Start" means that the boot
process will start Orthanc only when PostgreSQL is started?
Yes.

Karsten
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@hermes.hilbert.loc
Sébastien Jodogne
2015-03-06 10:24:11 UTC
Permalink
Post by Karsten Hilbert
The only way to usefully communicate that state is ...
Post by Sébastien Jodogne
If Orthanc is configured for PG but PG is not started,
Orthanc will stop, will *not* fallback to sqlite [, ...]
you have configured Orthanc to connect to PG with
$PG_CONN_STRING but I cannot connect with those
$LIBPQ_ERROR_MESSAGE (if any)
Yes, this is the current behavior:
# cat /var/log/orthanc/Orthanc.ERROR
E0305 17:02:20.518434 30901 PluginsManager.cpp:144] Error in PostgreSQL: FATAL: password authentication failed for user "postgres"
E0305 17:02:20.518726 30901 PluginsManager.cpp:82] Error while initializing plugin /usr/share/orthanc/plugins/libOrthancPostgreSQLStorage.so (code -1)
E0305 17:02:21.014979 30901 main.cpp:654] Uncaught exception, stopping now: [Error while using a shared library (plugin)]
<<<<<
Post by Karsten Hilbert
So, all in all the only useful purpose an orthanc-PG package
might serve is to Depends: on postgresql-*client* thereby
ensuring libpq is installed :-) thereby freeing the
orthanc(-core) package from that Depends:.
Yes, this is also the current state of the package.
Post by Karsten Hilbert
you might just do away with the whole gamut and have
orthanc(-core) just install everything (core and PG plugin)
and also Depends: on sqlite _and_ postgresql-client. It would
then provide a default configuration for sqlite and a
correct-but-inactive configuration for the PG plugin.
I do not want to include the PG plugins inside orthanc, as the two projects are fully separated (distinct repositories, distinct versioning).

OK, so, according to the KISS principle, I think I will choose the simplest way. There will be 2 packages: "orthanc" and "orthanc-postgresql", and I will discard "orthanc-sqlite". It will always be possible to introduce it in the future. I will also remove the "Conflicts:" and provide instructions/samples to modify the "/etc/orthanc/orthanc.json" file to enable PG support.

This should hopefully be ready for this afternoon.

Sébastien-
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@chu.ulg.ac.be
Karsten Hilbert
2015-03-06 11:01:18 UTC
Permalink
Post by Sébastien Jodogne
I will also remove the "Conflicts:" and
provide instructions/samples to modify the
"/etc/orthanc/orthanc.json" file to enable PG support.
You might even provide a commented out but working
configuration in orthanc.json with a comment saying
"if you want to use this you need to install orthanc-postgresql"

Karsten
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@hermes.hilbert.loc
Sébastien Jodogne
2015-03-06 10:26:46 UTC
Permalink
Post by Karsten Hilbert
Post by Sébastien Jodogne
I am unsure to understand the second part of this
paragraph: Does "Should-Start" only mean that when the
Orthanc service starts, PostgreSQL is guaranteed to start
during the boot process
No. To my understanding it means that the boot process will
attempt to start PG but not require that to succeed.
Post by Sébastien Jodogne
, but not necessarily *before* Orthanc?
No, IF it is started then it WILL be before Orthanc.
OK, I will thus introduce "Should-Start: postgresql" in the "orthanc.init" published by the "orthanc" package. This will not hurt, even if "orthanc-postgresql" is not installed.
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@chu.ulg.ac.be
Karsten Hilbert
2015-03-06 10:36:37 UTC
Permalink
Post by Sébastien Jodogne
Post by Karsten Hilbert
Post by Sébastien Jodogne
I am unsure to understand the second part of this
paragraph: Does "Should-Start" only mean that when the
Orthanc service starts, PostgreSQL is guaranteed to start
during the boot process
No. To my understanding it means that the boot process will
attempt to start PG but not require that to succeed.
Post by Sébastien Jodogne
, but not necessarily *before* Orthanc?
No, IF it is started then it WILL be before Orthanc.
OK, I will thus introduce "Should-Start: postgresql" in the
"orthanc.init" published by the "orthanc" package. This will
not hurt, even if "orthanc-postgresql" is not installed.
But it might hurt if PG is installed locally but Orthanc is
configured to conenct to a remote PG. In that case Orthanc
has no business meddling with the startup of a local PG.

Karsten
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@hermes.hilbert.loc
Andreas Tille
2015-03-06 12:07:41 UTC
Permalink
Hi Karsten,
Post by Karsten Hilbert
But it might hurt if PG is installed locally but Orthanc is
configured to conenct to a remote PG. In that case Orthanc
has no business meddling with the startup of a local PG.
I do not think that this is a problem. If PG is installed locally for
whatever purpose it will startup sooner or later. The effect of the
"Should-Start: postgresql" statement is just that orthanc will wait
for this start. I fail to see any problem in this approach.

Kind regards

Andreas.
--
http://fam-tille.de
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@an3as.eu
Sébastien Jodogne
2015-03-06 10:48:13 UTC
Permalink
Post by Karsten Hilbert
Post by Sébastien Jodogne
OK, I will thus introduce "Should-Start: postgresql" in the
"orthanc.init" published by the "orthanc" package. This will
not hurt, even if "orthanc-postgresql" is not installed.
But it might hurt if PG is installed locally but Orthanc is
configured to conenct to a remote PG. In that case Orthanc
has no business meddling with the startup of a local PG.
On the other hand, if this instruction is absent, the Orthanc service might crash at boot if it is configured to use the local PG.

The downside is that that the boot time might be delayed if:
(1) Orthanc uses SQLite or an external PG server, AND
(2) the local "postgresql" package is installed.

But as Orthanc starts very quickly (no JVM for instance), I think this is a rather theoretical problem. I think I will just add an explicit notice in the "orthanc/README.Debian", saying that to optimize the boot time, the "Should-Start: postgresql" can be safely removed from "/etc/init.d" if the 2 conditions above are met.
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@chu.ulg.ac.be
Karsten Hilbert
2015-03-06 10:59:01 UTC
Permalink
Post by Sébastien Jodogne
Post by Karsten Hilbert
Post by Sébastien Jodogne
OK, I will thus introduce "Should-Start: postgresql" in the
"orthanc.init" published by the "orthanc" package. This will
not hurt, even if "orthanc-postgresql" is not installed.
But it might hurt if PG is installed locally but Orthanc is
configured to conenct to a remote PG. In that case Orthanc
has no business meddling with the startup of a local PG.
On the other hand, if this instruction is absent, the
Orthanc service might crash at boot if it is configured to
use the local PG.
I see. That's true.

If it seems to become a problem later on we can always remove
it again.

Karsten
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
--
To UNSUBSCRIBE, email to debian-med-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Archive: https://lists.debian.org/***@hermes.hilbert.loc
Loading...