Skip to content

New instances are not redirected to daemon and delete .config-lock #2730

@BrutuZ

Description

@BrutuZ

Expected behaviour:

Commands issued from console window interact with current running daemon

Actual behaviour:

Commands run as stand-alone and delete the .config-lock file which keeps relevant info regarding the running daemon.

Steps to reproduce:

  • Step 1: Start daemon
  • Step 2: Run a command
  • Step 3: Verify that both the daemon is still running and the config-lock file is gone

Config:

Anything with a schedule that'll keep the daemon running

schedules:
  - tasks: [test]
    schedule:
      minute: 5
tasks:
  test:
    mock: {title: 'foo'}
    exec: echo bar

Log:

(click to expand)
$ type .config-lock
PID: 12204
password: csytv7S1RG1BiwG
port: 58500

$ tasklist /FI "PID eq 12204"

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
pythonw.exe                  12204 Services                   0      5,680 K

$ flexget daemon status
2020-09-20 13:58:04 ERROR    manager                       There does not appear to be a daemon running.

$ type .config-lock
The system cannot find the file specified.

$ tasklist /FI "PID eq 12204"

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
pythonw.exe                  12204 Services                   0      5,220 K

$ echo Waiting for Task Scheduler script to kill current daemon and spawn new one
Waiting for Task Scheduler script to kill current daemon and spawn new one

$ tasklist /FI "PID eq 12204"
INFO: No tasks are running which match the specified criteria.

$ type .config-lock
PID: 10824
password: Ajs3wZEn7SErCyc
port: 59135

$ tasklist /FI "PID eq 10824"

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
pythonw.exe                  10824 Services                   0     65,204 K

$ flexget execute --task http-ddl
2020-09-20 14:10:45 VERBOSE  task_queue                    There are 1 tasks to execute. Shutdown will commence when they have completed.
2020-09-20 14:10:47 VERBOSE  rss           http-ddl        Not processing entries from last run.
2020-09-20 14:10:47 VERBOSE  details       http-ddl        Produced 100 entries.
2020-09-20 14:10:47 VERBOSE  details       http-ddl        Summary - Accepted: 0 (Rejected: 0 Undecided: 100 Failed: 0)

$ type .config-lock
The system cannot find the file specified.

$ tasklist /FI "PID eq 10824"

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
pythonw.exe                  10824 Services                   0    121,496 K

Launch Script Excerpt:

launch.bat

REM Check for .config-lock. If exists also validate it's not a leftover from previous sessions (aka the process that created still exists).
REM If it doesn't, try to send the API a shutdown request just in case so we can spawn a new process with proper .config-lock
if EXIST ".config-lock" (
	for /F "usebackq tokens=2" %%i in (`findstr "PID" ".config-lock"`) do (
		tasklist /FI "PID eq %%i"|find "pythonw.exe"&&goto:eof
		del ".config-lock"
		echo %DATE% %TIME% Deleting .config-lock...
	)
) else (
	for /F "usebackq tokens=2" %%i in (`flexget web showtoken`) do (
		curl -s -X POST --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: Token %%i" -d "{\"operation\": \"shutdown\"}" "http://localhost:5050/api/server/manage/"
	)
)

REM "Fancy" update from git goes here

flexget-headless -l "%USERPROFILE%\flexget\logs\flexget.log" daemon start --autoreload-config

Additional information:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions