Created attachment 40548 [details] [review] Bug 14448 - Set up logging and configuration file reading for Mojolicious. Use environmental values to control some aspects of Mojolicious: This way we can have different settings for different servers running Mojolicious. %%%% Configuration file %%%% $ENV{MOJO_CONFIG} should be set in the system service (init) starting Mojolicious, eg: export MOJO_CONFIG=/home/koha/kohaclone/api/v1/hypnotoad.conf This configuration file read by the Mojolicious::Plugin::Config http://mojolicio.us/perldoc/Mojolicious/Plugin/Config %%%%% Logging %%%%% >NOTE!! >There is a "feature" in Mojo::Server disabling STDOUT and STDERR, because such errors are not-suited-for-prod~ >This modification in Mojo::Server disables this and preserves the STD* handles for forked server threads >in Mojo::Server::daemonize(), comment out the following lines > ># Close filehandles ># open STDOUT, '>/dev/null'; ># open STDERR, '>&STDOUT'; Log to a filename configured in an environemnt variable $ENV{MOJO_LOGFILE} using loglevel $ENV{MOJO_LOGLEVEL}. Defaults to '/tmp/koha-api.log' and loglevel of 'error' Examples: export MOJO_LOGFILE=/home/koha/koha-dev/var/log/kohaapi.mojo.log export MOJO_LOGLEVEL=debug Logging is done by Mojo::Log http://www.mojolicio.us/perldoc/Mojo/Log
Created attachment 40549 [details] [review] Bug 14448 - Adding the REST API as a Hypnotoad service, koha-api-daemon. After running make, the koha-api-daemon.sh -script should be in ../koha-dev/bin/koha-api-daemon.sh Link it to the init-directory and set up upstart triggers: ..$ ln -s /home/koha/koha-dev/bin/koha-api-daemon.sh /etc/init.d/koha-api-daemon ..$ update-rc.d koha-api-daemon defaults Start hypnotoad: ..$ service koha-api-daemon start Hypnotoad is now listening in 127.0.0.1:8080 and is preconfigured to be production ready. Hypnotoad config is in $KOHA_PATH/api/v1/hypnotoad.conf For more info, read the koha-api-daemon.sh -service
Created attachment 40550 [details] [review] Bug 14448 - Nginx reverse proxy config baseline for Koha REST API. Tweaking needed to work with makefile. Uses a self-signed SSL-certificate to service at port 444 by default. Reverse proxies to 127.0.0.1:8080 (expecting hypnotoad to be listening) ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ ¤¤ Koha API Nginx configuration ¤¤ ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ Deploy the Nginx configuration ------------------------------ Run make to populate the koha-nginx-kohaapi.conf link to the /etc/nginx/sites-available/ -directory ..$ ln -s /home/koha/koha-dev/etc/koha-nginx-kohaapi.conf /etc/nginx/sites-available/kohaapi and enable with command ..$ ln -s /etc/nginx/sites-available/kohaapi /etc/nginx/sites-enabled/kohaapi Disable the default config ..$ rm /etc/nginx/sites-enabled/default Create a openssl self-signed certificate or use your own. --------------------------------------------------------- ..$ cd /etc/nginx ..$ mkdir ssl ..$ chmod 400 ssl ..$ cd ssl ..$ openssl req -x509 -sha256 -newkey rsa:2048 -keyout key.pem.secure -out cert.pem -days 720 ..$ openssl rsa -in key.pem.secure -out key.pem ..$ chmod 400 * Restart nginx ..$ service nginx restart
Created attachment 41168 [details] [review] Bug 14448 - Adding the REST API as a Hypnotoad service, koha-api-daemon.
Created attachment 41169 [details] [review] Bug 14448 - Nginx reverse proxy config baseline for Koha REST API. Tweaking needed to work with makefile.
Created attachment 41333 [details] [review] Bug 14448 - Adding the REST API as a Hypnotoad service, koha-api-daemon.
Created attachment 41334 [details] [review] Bug 14448 - Nginx reverse proxy config baseline for Koha REST API. Tweaking needed to work with makefile.
Created attachment 41545 [details] [review] Bug 14448 - Adding the REST API as a Hypnotoad service, koha-api-daemon.
Created attachment 41546 [details] [review] Bug 14448 - Nginx reverse proxy config baseline for Koha REST API. Tweaking needed to work with makefile.
What is the status of this work?
Hi! I managed to get starman, the plack-server to do hot-reloads, so we might not be interested in maintaining Hypnotoad. Community runs the REST API on starman and this is the most convenient thing to do. I tried to get rid of Apache by running only starman behind haproxy, but starman couldn't beat apache2 in static content delivery so we still have apace2 around. The less services we need to run Koha, the better. So this feature is not maintained by us.