Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mediamon not working after reboot #14

Open
fedotov371 opened this issue Jan 8, 2019 · 14 comments
Open

mediamon not working after reboot #14

fedotov371 opened this issue Jan 8, 2019 · 14 comments

Comments

@fedotov371
Copy link

fedotov371 commented Jan 8, 2019

DSM 6.2.1-23824 Update 2

Hello guys, i have the problem.
If i write on ssh:
/usr/local/etc/rc.d/S99mediamon.sh start
Mediamon working and for each new media file have "synoindex" on log file.

If i write on ssh:
ps -fHu root
Get:
python3 /volume1/homes/admin/mediamon.py

After reboot my synology nas in /var/log/mediamon.log have a new string "Starting", but mediamon not see new media files. If i write on ssh: "ps -fHu root" - don't see task mediamon. If i run mediamon manually on ssh - it's working. After reboot - not working, but in log have string "Starting".

Why mediamon need run manually every time after reboot nas?

@fedotov371 fedotov371 changed the title mediamon now working after reboot mediamon not working after reboot Jan 8, 2019
@Tstassin
Copy link

Tstassin commented Jan 8, 2019

You could use Synology Task Scheduler

@fedotov371
Copy link
Author

You could use Synology Task Scheduler

Thanks=) i try it.

Make new task for root on start system:
/usr/local/etc/rc.d/S99mediamon.sh start

After reboot get 2 strings "Starting" on log file. But mediamon not see new media files.
If i run mediamon manually on ssh - it's working.

@carljm
Copy link
Owner

carljm commented Jan 10, 2019

Sounds like mediamon is starting but then shutting down right away instead of continuing to run. I won't have time to look into this soon but if anyone figures out what's going on, I'd be happy to merge a pull request to fix!

@marcolino7
Copy link

Same issue there. If mediamon is run from Task Scheduler do not index new files, if it's run from command line it work fine.
I noticed that mediamon take lot of time to get started from command line 5 to 10 minutes, perhaps Task Scheduler have a timeout inside.

Please help

Many Thanks

Marco

@vordho
Copy link

vordho commented May 22, 2020

Hi.
Same issue there.

Working fine if started manually from the command line, but can't get it started at boot after copying S99mediamon.sh to /usr/local/etc/rc.d/ with 755 permissions.

I've tried to create a boot task with task manager but got this error back in email :

EDIT : I'm not a coder so i don't know if that help to solve the issue or if it's just a basic error.

Tâche : Mediamon

Heure de début : Fri, 22 May 2020 01:20:49 GMT
Heure d’arrêt : Fri, 22 May 2020 01:20:50 GMT
État actuel : 1 (Interrompu)
Sortie standard/erreur :
Traceback (most recent call last):
File “/volume1/homes/admin/mediamon.py”, line 132, in
exclude_filter=lambda p: ‘/@’ in p
File “/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/pyinotify.py”, line 1916, in add_watch
exclude_filter)
File “/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/pyinotify.py”, line 1833, in __add_watch
wd = self._inotify_wrapper.inotify_add_watch(self._fd, path, mask)
File “/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/pyinotify.py”, line 153, in inotify_add_watch
return self._inotify_add_watch(fd, pathname, mask)
File “/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/pyinotify.py”, line 246, in _inotify_add_watch
pathname = pathname.encode(sys.getfilesystemencoding())
UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 72-73: ordinal not in range(128)

@Technosoft2000
Copy link

Technosoft2000 commented May 23, 2020

@fedotov371

The problem is that pyinotify typically doesn't work correctly with UTF-8 filenames.

so you've the same issue as described at Issue with automatic start #11

Here the important text from the post:

The issue is that I have some filenames that are not UTF-8 encoded, but my filesystem is UTF-8 (use python command “sys.getfilesystemencoding()” to get your filesystem encoding).
So, the real issue is that I have bad filenames. As I cannot fix easily those filenames, I have to live with them.

Here is what I did:
in /volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/pyinotify.py, line 246:

I have put:

pathname = pathname.encode(sys.getfilesystemencoding(), ‘surrogateescape’)

instead of

pathname = pathname.encode(sys.getfilesystemencoding())

IMPORTANT: after some Synology updates it could happen that this workaround will be overwritten again and you've to do it again :-/

@fedotov371
Copy link
Author

fedotov371 commented May 25, 2020

@Technosoft2000

Thanks, i do it.
And reboot nas twice=)
But not help for my nas.

If i run mediamon manually on ssh - it's working.

@tjuerges
Copy link

tjuerges commented Jun 16, 2020

You could also create a Python3 virtual environment, install pyinotify there and modify it:

cd wherever/mediamon
python3 -m venv env
source env/bin/activate
python3 -m pip install pyinotify

Now edit the file env/lib/python3.5/site-packages/pyinotify.py and add what @fedotov371 recommended.

Then make certain that the venv gets started before mediamon gets executed. Just add the source ... statement with the full path to the env directory to the start target. Be nice and also add deactivate just after the kill command in the stop target. That should do the trick.

@vovka36
Copy link

vovka36 commented Aug 5, 2020

Guys, I defeated this problem. There is works FINE now! (At least I have it worked)

In S99mediamon.sh I just replace this
python3 /volume1/homes/admin/mediamon.py
with
nohup env LC_ALL=en_US.utf8 python3 /volume1/mediamon.py
Of course you must to correct path to mediamon.py

There is NO need to install pyinotify as tjuerges wrote in previous comment and NO need to modify the file pyinotify.py as Technosoft2000 wrote.
Please write here if it helps you.

@tjuerges
Copy link

tjuerges commented Aug 6, 2020

Good find, indeed, @vovka36 ! 🍻

It appears that there is already the pyinotify module installed on the system. Hence the additional installation together with a venv is not needed.

@fedotov371
Copy link
Author

fedotov371 commented Aug 7, 2020

Guys, I defeated this problem. There is works FINE now! (At least I have it worked)

dont work(

if i run on putty
/usr/local/etc/rc.d/S99mediamon.sh start

get message:
nohup: ignoring input and appending output to ‘nohup.out’ -sh: nohup:: command not found

and on log file (it's new and good)
2020-08-07T15:14:27.386600 - Cannot daemonize: pid file /var/run/mediamon.pid already exists.

if i restart nas and download new video with Transmission - dont see this video on Video station.

@vovka36
Copy link

vovka36 commented Aug 7, 2020

@fedotov371 wich version of DSM you use?
I am on DSM 6.1.7-15284 Update 3
Message like you wrote sometimes written in my log too but it works fine

@fedotov371
Copy link
Author

@vovka36
DSM 6.2.1-23824 Update 2

I'll try to do something else tomorrow.

@fedotov371
Copy link
Author

fedotov371 commented Oct 29, 2020

Yes, it's work fine.

@vovka36 Good joob, comrade:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants