Closed Aqualie closed 1 year ago
Can you check for me that /opt/rtorrent/.pyrosimple/run/pyrotorque.pid
is writeable by the process? It looks like that can make it fail silently currently.
? ~ pyrotorque
? ~ pyrotorque --status
ERROR:pyrosimple.scripts.pyrotorque.RtorrentQueueManager:No pyrotorque process found.
? ~ ls -lha /opt/rtorrent/.pyrosimple/run/
total 12K
drwxr-xr-x 1 rtorrent rtorrent 4.0K Jul 15 18:34 .
drwxr-xr-x 1 rtorrent rtorrent 4.0K Jul 15 18:33 ..
? ~ touch /opt/rtorrent/.pyrosimple/run/123
? ~ ls -lha /opt/rtorrent/.pyrosimple/run/
total 12K
drwxr-xr-x 1 rtorrent rtorrent 4.0K Jul 15 18:34 .
drwxr-xr-x 1 rtorrent rtorrent 4.0K Jul 15 18:33 ..
-rw-r----- 1 rtorrent rtorrent 0 Jul 15 18:34 123
? ~
I presume it would be running as the same user I'm running the command as?
Correct, you can actually see it in the strace:
setgid(1002) = 0
setuid(1001) = 0
Can you try the latest code for me?
pip install -U https://github.com/kannibalox/pyrosimple/archive/refs/heads/main.tar.gz
I've added a more generic lockfile test prior to forking, and if that doesn't turn anything up, try the new --log-file <path>
flag to set the stdout/stderr to a specific file.
Seems better now but failing on the rtorrent connection for some reason:
rtorrent [ ~ ]$ pyrotorque --debug --verbose --log-file /opt/rtorrent/pryotorque.log
INFO:pyrosimple.scripts.pyrotorque.RtorrentQueueManager:Writing pid to /opt/rtorrent/.pyrosimple/run/pyrotorque.pid and detaching process...
INFO:pyrosimple.scripts.pyrotorque.RtorrentQueueManager:Logging stderr/stdout to <_io.TextIOWrapper name='/opt/rtorrent/pryotorque.log' mode='w' encoding='UTF-8'>
rtorrent [ ~ ]$ cd^C
rtorrent [ ~ ]$ ps -a
PID TTY TIME CMD
59 pts/1 00:00:00 bash
64 pts/1 00:03:28 rtorrent main
91 pts/2 00:00:00 ps
rtorrent [ ~ ]$ cat pyrotorque.log
/opt/rtorrent/.local/lib/python3.11/site-packages/tzlocal/unix.py:192: UserWarning: Can not find any timezone configuration, defaulting to UTC.
warnings.warn("Can not find any timezone configuration, defaulting to UTC.")
Traceback (most recent call last):
File "/opt/rtorrent/.local/bin/pyrotorque", line 8, in <module>
sys.exit(run())
^^^^^
File "/opt/rtorrent/.local/lib/python3.11/site-packages/pyrosimple/scripts/pyrotorque.py", line 292, in run
RtorrentQueueManager().run()
File "/opt/rtorrent/.local/lib/python3.11/site-packages/pyrosimple/scripts/base.py", line 177, in run
self.mainloop()
File "/opt/rtorrent/.local/lib/python3.11/site-packages/pyrosimple/scripts/pyrotorque.py", line 284, in mainloop
self.add_jobs()
File "/opt/rtorrent/.local/lib/python3.11/site-packages/pyrosimple/scripts/pyrotorque.py", line 122, in add_jobs
self.classes[name] = params["__handler"](params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/rtorrent/.local/lib/python3.11/site-packages/pyrosimple/job/watch.py", line 50, in __init__
self.engine.open()
File "/opt/rtorrent/.local/lib/python3.11/site-packages/pyrosimple/torrent/rtorrent.py", line 698, in open
self.properties = self.system_multicall(
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/rtorrent/.local/lib/python3.11/site-packages/pyrosimple/torrent/rtorrent.py", line 678, in system_multicall
for index, r in enumerate(self.rpc.system.multicall(call)):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/xmlrpc/client.py", line 1122, in __call__
return self.__send(self.__name, args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/rtorrent/.local/lib/python3.11/site-packages/pyrosimple/util/rpc.py", line 244, in __request
return self.__request_switch(methodname, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/rtorrent/.local/lib/python3.11/site-packages/pyrosimple/util/rpc.py", line 258, in __request_switch
return self.__request_xml(methodname, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/rtorrent/.local/lib/python3.11/site-packages/pyrosimple/util/rpc.py", line 137, in __request_xml
response = self.__transport.request(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/rtorrent/.local/lib/python3.11/site-packages/pyrosimple/io/scgi.py", line 136, in request
sock.connect(target)
FileNotFoundError: [Errno 2] No such file or directory
And yet it's working fine when run in the foreground, or via simple rtxmlrpc
commands? The pyrocore.job.watch:TreeWatch
job is a little special in that it's one of the few ones that actually needs to check if rtorrent is running on initialization, but other than that it shouldn't connect differently in a backgrounded pyrotorque than any other setup.
Also specifying --debug --verbose
in that order will make "verbose" override "debug". Just --debug
will get you both levels.
Yes that's right when running in FG mode it works just fine:
rtorrent [ ~ ]$ pyrotorque --debug --fg
DEBUG:pyrosimple.scripts.pyrotorque.RtorrentQueueManager:Options: dry_run=False, log_file=None, log_level=10, no_fork=True, pid_file=PosixPath('~/.pyrosimple/run/pyrotorque.pid'), print_completion=None, restart=False, run_once=None, status=False, stop=False, url=None
DEBUG:pyrosimple.config:Configuration file '/opt/rtorrent/.config/pyrosimple/config.py' not found.
/opt/rtorrent/.local/lib/python3.11/site-packages/tzlocal/unix.py:192: UserWarning: Can not find any timezone configuration, defaulting to UTC.
warnings.warn("Can not find any timezone configuration, defaulting to UTC.")
2023-07-15 23:55:18,270 DEBUG pyrosimple.config: Loading rtorrent config from '/opt/rtorrent/.rtorrent.rc'
2023-07-15 23:55:18,271 DEBUG pyrosimple.config: rtorrent.rc: network.scgi.open_local = /opt/rtorrent/.scgi_local
2023-07-15 23:55:18,271 DEBUG pyrosimple.pyrotorque.jobs.queue: pyrosimple.job.base:queue created with config {'handler': 'pyrocore.job.queue:QueueManager', 'schedule': {'second': '*/15'}, 'active': True, 'dry_run': False, 'sort_fields': '-prio,loaded,name', 'downloading_min': 1, 'downloading_max': 9, 'start_at_once': 4, 'intermission': 0, 'startable': 'is_ignored=0 done=0 message="" prio>0', '__handler': <class 'pyrosimple.job.queue.QueueManager'>, '__job_name': 'queue', 'matcher': 'is_ignored=0 done=0 message="" prio>0', 'sort': '-prio,loaded,name'}
2023-07-15 23:55:18,272 DEBUG pyrosimple.torrent.rtorrent: Validated key names: -prio, loaded, name
2023-07-15 23:55:18,272 INFO pyrosimple.pyrotorque.jobs.queue: Startable matcher is: is_ignored=0 done=0 message="" prio>0
2023-07-15 23:55:18,272 INFO pyrosimple.pyrotorque.jobs.queue: Downloading matcher is: OrNode["AndNode['BoolFilter', 'BoolFilter']"]
2023-07-15 23:55:18,370 DEBUG pyrosimple.pyrotorque.jobs.stats: pyrosimple.job.base:stats created with config {'handler': 'pyrocore.job.metrics:EngineStats', 'schedule': {'minute': '*'}, 'active': True, 'dry_run': False, '__handler': <class 'pyrosimple.job.metrics.EngineStats'>, '__job_name': 'stats'}
2023-07-15 23:55:18,370 DEBUG pyrosimple.pyrotorque.jobs.watch: pyrosimple.job.base:watch created with config {'handler': 'pyrocore.job.watch:TreeWatch', 'schedule': {'second': '*/5'}, 'active': True, 'dry_run': False, 'load_mode': 'start', 'cmd_queue': 'd.priority.set=0', 'path': '/media/tmp/watch/start', '__handler': <class 'pyrosimple.job.watch.TreeWatch'>, '__job_name': 'watch'}
2023-07-15 23:55:18,370 DEBUG pyrosimple.util.rpc: method 'system.multicall', params ([{'methodName': 'system.client_version', 'params': []}, {'methodName': 'system.library_version', 'params': []}, {'methodName': 'system.time_usec', 'params': []}, {'methodName': 'session.name', 'params': []}, {'methodName': 'directory.default', 'params': []}, {'methodName': 'session.path', 'params': []}],)
2023-07-15 23:55:18,371 DEBUG pyrosimple.util.rpc: method 'startup_time', params ()
2023-07-15 23:55:18,372 DEBUG pyrosimple.torrent.rtorrent.RtorrentEngine: RtorrentEngine connected to localhost:64 [rTorrent 0.13.8/0.9.8] via 'scgi+unix:///opt/rtorrent/.scgi_local'
Strange after this I ran it again and now it appears to be already working:
rtorrent [ ~ ]$ pyrotorque --debug --log-file /opt/rtorrent/pryotorque.log
DEBUG:pyrosimple.scripts.pyrotorque.RtorrentQueueManager:Options: dry_run=False, log_file=PosixPath('/opt/rtorrent/pryotorque.log'), log_level=10, no_fork=False, pid_file=PosixPath('~/.pyrosimple/run/pyrotorque.pid'), print_completion=None, restart=False, run_once=None, status=False, stop=False, url=None
DEBUG:pyrosimple.config:Configuration file '/opt/rtorrent/.config/pyrosimple/config.py' not found.
ERROR:pyrosimple.scripts.pyrotorque.RtorrentQueueManager:Cannot lock pidfile: /opt/rtorrent/.pyrosimple/run/pyrotorque.pid is already locked
INFO:pyrosimple.scripts.pyrotorque.RtorrentQueueManager:Total time: 0.235 seconds.
rtorrent [ ~ ]$ pyrotorque --status --debug
DEBUG:pyrosimple.scripts.pyrotorque.RtorrentQueueManager:Options: dry_run=False, log_file=None, log_level=10, no_fork=False, pid_file=PosixPath('~/.pyrosimple/run/pyrotorque.pid'), print_completion=None, restart=False, run_once=None, status=True, stop=False, url=None
DEBUG:pyrosimple.config:Configuration file '/opt/rtorrent/.config/pyrosimple/config.py' not found.
INFO:pyrosimple.scripts.pyrotorque.RtorrentQueueManager:Pyrotorque is running (PID 87).
INFO:pyrosimple.scripts.pyrotorque.RtorrentQueueManager:Total time: 0.186 seconds.
rtorrent [ ~ ]$ ps -A | grep pyrotorque
87 ? 00:04:36 pyrotorque
Sorry, but it's not clear to me, are all your problems resolved now?
Hi I tested restarting the container and found the pyrotorque.pid file still existed so it prevented it from starting again.
ERROR:pyrosimple.scripts.pyrotorque.RtorrentQueueManager:Cannot lock pidfile: /opt/rtorrent/.pyrosimple/run/pyrotorque.pid is already locked
I guess I can just add a simple delete file command prior to lauching pyrotorque
I just added a simple clean-up script before starting pyrotorque does the trick.
I'm still doing some testing/other work so it's not released yet, but I've also added a --adopt-stale-pid-file
flag for pyrotorque
When running pyrotorque in default daemon/detached mode it simply just exits and doesn't start:
working in FG mode