Skip to content

Commit

Permalink
Only load shared libraries when needed
Browse files Browse the repository at this point in the history
libzmq and libssl are only needed when running in standalone mode.
Unload the shared objects before dumping the image (so that the
implementation does not try to load them automatically on startup),
and only load them when running in server mode.
  • Loading branch information
jdz committed Feb 4, 2020
1 parent 9fe8bae commit eff2fb3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
7 changes: 3 additions & 4 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This is ~pastelyzer~: the paste analyzer. The user manual can be found in

The easiest way to run ~pastelyzer~ is by using the provided binary.

* Runtime dependencies
* Runtime dependencies (standalone mode only)
** Libraries

The following libraries must be installed on the target system:
Expand All @@ -26,9 +26,8 @@ The following libraries must be installed on the target system:

** Database

To run ~pastelyzer~ in standalone mode a PostgreSQL database (at least version
*9.5*) is required. Use the SQL script in
[[file:support/schema.sql][support/schema.sql]] to initialize the database:
PostgreSQL database (at least version *9.5*) is required. Use the SQL script
in [[file:support/schema.sql][support/schema.sql]] to initialize the database:

#+BEGIN_EXAMPLE
$ psql -d pastelyzer < support/schema.sql
Expand Down
4 changes: 4 additions & 0 deletions bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ case "$OPERATION" in
--eval "(asdf:load-system \"pastelyzer\")" \
--eval "(setq pastelyzer::*build-id* ${BUILD_ID})" \
--eval "(proclaim '(optimize (speed 2) (safety 1)))" \
--eval "(asdf:load-system \"pastelyzer\")" \
--eval "(cffi:close-foreign-library 'pzmq::libzmq)" \
--eval "(cffi:close-foreign-library 'cl+ssl::libssl)" \
--eval "(cffi:close-foreign-library 'cl+ssl::libcrypto)" \
--eval "(asdf:make \"pastelyzer\")"
if [ -f "${BINDIR}/pastelyzer" ]; then
mv -f "${BINDIR}/pastelyzer" "${BINDIR}/pastelyzer.old"
Expand Down
7 changes: 7 additions & 0 deletions src/pastelyzer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,13 @@
(setf (puri:uri-host *web-server-external-uri*) web-server-external-host))
(when web-server-external-port
(setf (puri:uri-port *web-server-external-uri*) web-server-external-port))

;; We unload foreign libraries required to run in server mode before
;; dumping the image so that the CLI version can be used without
;; these.
(cl+ssl:reload)
(cffi:load-foreign-library 'pzmq::libzmq)

(let* ((store-queue (create-queue :store))
(process-queue (create-queue :process))
;; Separate queue for big pastes.
Expand Down

0 comments on commit eff2fb3

Please sign in to comment.