Bug 36932 - koha-plack: Add parameter for specifically enabling Starman development environment
Summary: koha-plack: Add parameter for specifically enabling Starman development envir...
Status: Failed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: Marcel de Rooy
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-23 06:49 UTC by Marcel de Rooy
Modified: 2024-10-26 18:48 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
To be safer, we default to deployment environment. The -dev parameter allows you to switch to development.
Version(s) released in:
Circulation function:


Attachments
Bug 36932: Add deployment parameter to koha-plack (1.68 KB, patch)
2024-05-23 07:07 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 36932: Add deployment parameter to koha-plack (1.70 KB, patch)
2024-05-30 02:38 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 36932: Add development parameter to koha-plack (2.71 KB, patch)
2024-09-27 08:49 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel de Rooy 2024-05-23 06:49:56 UTC
Allow to control these parts of the script in particular:

    if [ "$DEV_INSTALL" = "1" ]; then
        # Maybe we should switch off debug_mode if DEV_INSTALL is not set?
        environment="development"
    fi

and 

    if [ "$debug_mode" = "yes" ]; then
        environment="development"
Comment 1 Marcel de Rooy 2024-05-23 07:07:34 UTC
Created attachment 167069 [details] [review]
Bug 36932: Add deployment parameter to koha-plack

Test plan (needs dev_install or ktd):
Add a die in a script somewhere to simulate a crash.
* For example in opac-main.pl: die "Line 43";
Run koha-plack --restart without -dep and hit that page. Dev output?
Run koha-plack --restart with -dep and hit page again. No dev output?

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 2 Victor Grousset/tuxayo 2024-05-28 19:53:14 UTC
Is that to make running KTD in production safer?
Comment 3 Victor Grousset/tuxayo 2024-05-28 20:02:16 UTC
Or to someone needing to briefly enable debug mode in production?
Comment 4 Marcel de Rooy 2024-05-29 11:38:36 UTC
(In reply to Victor Grousset/tuxayo from comment #2)
> Is that to make running KTD in production safer?

(In reply to Victor Grousset/tuxayo from comment #3)
> Or to someone needing to briefly enable debug mode in production?

The patch allows you to make a DEV_INSTALL (gitified package install, not only KTD) safer whether you want that in production or test environment.
Comment 5 Victor Grousset/tuxayo 2024-05-29 18:12:30 UTC
Ok, so like someone deploying koha with branches for flexibility of managing additional patches? Which would still be using the commands like koha-plack.
Comment 6 Victor Grousset/tuxayo 2024-05-30 02:38:56 UTC
Created attachment 167256 [details] [review]
Bug 36932: Add deployment parameter to koha-plack

Test plan (needs dev_install or ktd):
Add a die in a script somewhere to simulate a crash.
* For example in opac-main.pl: die "Line 43";
Run koha-plack --restart without -dep and hit that page. Dev output?
Run koha-plack --restart with -dep and hit page again. No dev output?

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 7 Victor Grousset/tuxayo 2024-05-30 02:54:56 UTC
It works! :)


---


Clarification:

> like someone deploying koha with branches 

* with a git repo to be able to use branches


---

Not sure about the -dep , it sounds like dependency instead of deployment. No big deal if nothing else sounds better.


---


new param is not documented in the --help

---


Since it's a safeguard to make sure people don't expose errors info in production: shouldn't it be the opposite approach? So like a -dev flag that ktd would have to add in it's startup command line call to koha-plack.

Wait, here with the current proposal it's very easy to switch back to an unsafe state: restart plack without putting the flag again.
How do the people in the usecases needing this flag manage the automated startup of koha on machine boot?
Because that place will need also to not have the -dep forgotten.

Do we have any setting that we already have to a value for dev envs and another one for regular prod instances and prod instance using a gittified setup? (IIUC that's the usecase for this flag).
How do we do it? ENV var that KTD overides and everywhere else it's a prod oriented value?
koha-conf.xml attribute that the KTD startup replaces with a dev oriented value so the everywhere else it's a prod oriented value?
Comment 8 Marcel de Rooy 2024-05-30 06:27:36 UTC
(In reply to Victor Grousset/tuxayo from comment #5)
> Ok, so like someone deploying koha with branches for flexibility of managing
> additional patches? Which would still be using the commands like koha-plack.

Yeah possibly.
Comment 9 Marcel de Rooy 2024-05-30 09:38:50 UTC
(In reply to Victor Grousset/tuxayo from comment #7)
> Not sure about the -dep , it sounds like dependency instead of deployment.
> No big deal if nothing else sounds better.
> 
> 
> ---
> 
> 
> new param is not documented in the --help
> 
> ---
> 
> 
> Since it's a safeguard to make sure people don't expose errors info in
> production: shouldn't it be the opposite approach? So like a -dev flag that
> ktd would have to add in it's startup command line call to koha-plack.
> 
> Wait, here with the current proposal it's very easy to switch back to an
> unsafe state: restart plack without putting the flag again.
> How do the people in the usecases needing this flag manage the automated
> startup of koha on machine boot?
> Because that place will need also to not have the -dep forgotten.
> 
> Do we have any setting that we already have to a value for dev envs and
> another one for regular prod instances and prod instance using a gittified
> setup? (IIUC that's the usecase for this flag).
> How do we do it? ENV var that KTD overides and everywhere else it's a prod
> oriented value?
> koha-conf.xml attribute that the KTD startup replaces with a dev oriented
> value so the everywhere else it's a prod oriented value?

Coming back a bit later for these things. Since we are in 24.11 now, blocking this one temporarily.
Comment 10 Marcel de Rooy 2024-09-27 08:49:59 UTC
Created attachment 172101 [details] [review]
Bug 36932: Add development parameter to koha-plack

Test plan:
NOTE: Needs dev_install or ktd.

[1] Add a die in a script somewhere to simulate a crash.
    For example in opac-main.pl: die "Line 43";
[2] Run koha-plack --restart YOUR_CLONE (without -dev) and hit that page.
    See no dev output?
[3] Run koha-plack --restart -dev YOUR_CLONE and hit page again.
    See dev output?
[4] BONUS: Do a koha-plack --reload YOUR_CLONE (without -dev). Hit page.
    Verify that environment did not change.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 11 David Nind 2024-10-26 18:48:14 UTC
This works, however the help needs to match the actual command (or vice versa):

1. Using -dev works: koha-plack --restart -dev kohadev

2. Using --development doesn't work: koha-plack --restart --development kohadev
   ==> Error: invalid option switch (--development)

3. Using --development_environment works. However, this is inconsistent with other options - should be a dash instead of an underscore. In addition, this doesn't match the help, which has --development.

Testing notes using KTD:

1. Apply the patch.

2. Reset everything: reset_all

3. Check that the script is updated: koha-plack --help
   ==> You should see the new option listed in the help output (--development|-dev    Enable development environment)

4. Run the rest of the test plan.


Help output
===========

koha-plack --help
koha-plack

This script lets you manage the plack daemons for your Koha instances.

Usage:
koha-plack --start|--stop|--restart|--reload|--status [--quiet|-q] instancename1 [instancename2...]
koha-plack --enable|--disable instancename1 [instancename2]
koha-plack -h|--help

    --start               Start the plack daemon for the specified instances
    --stop                Stop the plack daemon for the specified instances
    --restart             Restart the plack daemon for the specified instances
    --reload              Reload the plack daemon for the specified instances,
                          letting the busy workers finish processing their
                          requests before restarting them
    --enable              Enable plack for the specified instances
    --disable             Disable plack for the specified instances
    --status              Show the status of Plack for the specified instances
    --debugger            Enable running Plack in debug mode
    --debugger-key        Specify the key the IDE is expecting
    --debugger-location   Specify the host:port for your debugger tool (defaults
                          to localhost:9000)
    --debugger-path       Specify the path for the debugger library
    --development|-dev    Enable development environment
    --quiet|-q            Make the script quiet about non existent instance names
                          (useful for calling from another scripts).
    --help|-h             Display this help message