sabnzbd / sickbeard / couchpotato pbi's

Status
Not open for further replies.

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Do you understand how it's getting status? It looks like to me it's opening /var/run/transmission_fcgi_server.pid, and if it exists it say the service is running. But transmission could be stopped and /var/run/transmission_fcgi_server.pid will still give the pdfile of the fastcgi server.

Reading the documentation it seems we use control to run control.py or .php. I don't want to haev to bring in php just to control this thing so python would be ideal.
 

William Grzybowski

Wizard
iXsystems
Joined
May 27, 2011
Messages
1,754
You're not getting it... Unfortunately there isn't a official doc yet so it is quite hard to understand...

FreeNAS communicates with plugins using an interface... This interface is done using HTTP requests through FastCGI...
For instance, FreeNAS GUI get the status of a service by issuing HTTP GET request to /plugins/<plugin_name>/_s/status, and then the plugin will answer with the plugin status.

So, you'll need that your plugin run a FastCGI server so it can communicate with FreeNAS GUI.

In official transmission and firefly it runs Django, in minidlna it runs PHP.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
k thanks, slowly starting to get it, very slowloy lol

So http://freenasip/plugins/transmission/_s/status
gives me
{"status": "STOPPED", "pid": null}

how is this being generated? by the fastcgi server?
Where can I find the code that shows the fastcgi server checking if transmission is started?

Thanks for the help
 

William Grzybowski

Wizard
iXsystems
Joined
May 27, 2011
Messages
1,754
Correct, by the Django app being served via FastCGI...

The django app can be reached in /usr/pbi/transmission-amd64/freenasUI

The method that generates /_s/stautus can be found in /usr/pbi/transmission-amd64/freenasUI/freenas/views.py in "def status(request..."
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Awesome, I'll look into this a bit.

By the way almost done with v0.7, I'm just cleaning up the source for the programs by removing the dependencies that already ship with the freenas jail and shipping the python programs with the pbi. Created pidfiles in the /data directory. making the stop command try stopping the programs by fetching the shutdown url, then run a while loop that waits a few seconds to kill the program, might eventually put 'kill -9' after but that might be too messy.
 

ProtoSD

MVP
Joined
Jul 1, 2011
Messages
3,348
It seems control.py checks the status from /var/run/transmission_fcgi_server.pid
Thing is, I don't get how this works, where transmission is on or off, tranmission_fcgi_server is on (I believe this is what controls transmission). So I don't get how freenas suddenly knows transmission itself is on or off. Transmission creates it's own seperate pidfile and process.

I agree it's definitely a bit confusing. I've been digging into this myself, the transmission_FCGI_server.pid, is the PID of control.py (Fast CGI server) not the plugin. The plugin needs to generate it's own pid. The really good stuff is in transmissionUI/freenas/views.py, there's a popen command that runs the rc.d script for your plugin. When it kicks of the rc file and *returns properly*, then views.py will change the status to ON. There's a lot more to it than that, but generally that's what happens. I'm still trying to figure it out, but will *hopefully* have Serviio ready soon. Everytime I say that though, I run into another problem! So just cross your fingers and I'll start a new thread for it when it's ready.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Interesting, it seems views.py is using onestart / onestop / onestatus, this allows it to use rc.d without having to edit /etc/rc.conf. Though I don't know why they choose to do this.
Because, I did notice everytime I enable / disable transmission from the gui it edits /etc/rc.conf to add the transmission_enable="YES" command. This will mean that when the jail gets rebooted it will revert to the previous state.

Also noticed it uses pgrep to check status, this wont work for the sab suite becuase they all will only respond to python. We could use the pidfile or preferibly the rc.d which uses the pidfile now.
 

djoole

Contributor
Joined
Oct 3, 2011
Messages
158
Interesting, it seems views.py is using onestart / onestop / onestatus, this allows it to use rc.d without having to edit /etc/rc.conf.
/etc/rc.subr power

I did notice everytime I enable / disable transmission from the gui it edits /etc/rc.conf to add the transmission_enable="YES" command. This will mean that when the jail gets rebooted it will revert to the previous state.
The jail doesn't suffer the same "limitations" than FreeNAS. You won't loos anything inside the jail after reboot (/etc/rc.conf will be preserved)
 

ProtoSD

MVP
Joined
Jul 1, 2011
Messages
3,348
Also noticed it uses pgrep to check status, this wont work for the sab suite becuase they all will only respond to python. We could use the pidfile or preferibly the rc.d which uses the pidfile now.

Java apps have a similar problem, but you can still use pgrep to figure out which is which. If you set the user differently for each app, that will give you one unique thing to search for (pgrep -U user), then combine that with -f which searches the complete command line for a pattern like potato ;). You'll still need the pidfile.

It seems that since your plugins are Python based, it would be easier to integrate them with control.py/views.py etc. since I'm sure there are ways for the processes to communicate using python system calls.
 

ProtoSD

MVP
Joined
Jul 1, 2011
Messages
3,348
When you're done would you accept the challenge of making Logitech Media Server PBI? :D

Cringe, I already have a list and trust me, creating a plugin is no simple task, even if a port does exist for it. If you submit your request to the Plugin Request thread, that's where I'll look if I get bored and finish my list ;)
 

ProtoSD

MVP
Joined
Jul 1, 2011
Messages
3,348
What thread are you talking about?
This one http://forums.freenas.org/showthread.php?137-Do-You-Have-a-Plugin-Request
Or this one : http://forums.pcbsd.org/forumdisplay.php?f=61
I didn't want to make a PBI request on PCBSD forum because they need a port. And the Squeezebox Server Port has not been update since a long time. (I've made a fresh port request).

Yes, this one: http://forums.freenas.org/showthread.php?137-Do-You-Have-a-Plugin-Request

There's a port request link somewhere too, it might persuade them to update the outdated port. Having a port improves the process of creating a plugin, but that doesn't mean it's easy. We're still very early in FreeNAS plugin development and after some more time it will get easier with more documentation and tools to help.
 

djoole

Contributor
Joined
Oct 3, 2011
Messages
158
As I told in my previous post, i've made a port request already.
As for the plugin, it can wait, i have a LMS package easy to install (just excute an install script), and easy to update.

But i can't wait for Sab/Sick/couch/HP plugins or package 0.7 :)
Hopefully it will be available when i return in a big week
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
The jail doesn't suffer the same "limitations" than FreeNAS. You won't loos anything inside the jail after reboot (/etc/rc.conf will be preserved)

not what I meant, I just meant it makes sure the service starts when the jail reboots (by enabling it in rc.conf). I understand the entire jail is writeable / it's basically a standard freebsd system
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Sabnzbd / SickBeard / CouchPotato / Headphones / Maraschino - Pbi's v0.7

Version 0.7
- has switched completely to using pidfiles for status and to stop services
- doesn't package every needed dependency (ex python2.7), I cut out the ones that were preinstalled with the FreeNAS8.2RC1 Jail
- ships with usenet programs for quicker / more reliable install
- upgraded to couchpotato v2
- added maraschino

KNOWN BUGS (testers welcome!)
* sickbeard doesn't create pidfile, it checks for one though and doesn't start if it exists
* maraschino in general is not ready for production
- can't shutdown cleanly from commandline (try shutdown from gui first)
- forks into multiple processes, wont die unless you manually kill them all
- setting port in gui doesn't seem to work, edit /usr/local/etc/rc.d/maraschino to change port. We can set this with a config file but I decided not to implement this until the developer responds to my post in his xbmc forum thread

LINKS ~ password = usenet
64bit (11.6MB) ~ http://admin.joshuaruehlig.com//data/public/f05d2972cb305c144fbe489e4827bc21.php?lang=en
32bit (11.5MB) ~ http://admin.joshuaruehlig.com//data/public/878d72af66236b1106f11127ab5f8b8c.php?lang=en
Source (17MB) ~ http://admin.joshuaruehlig.com//data/public/296f2ae95fbc79fa2bd8876f60be75e9.php?lang=en

TODO
- start/stop/status from gui
- backup / restore 'data/' from gui
- update sabnzbd from gui
- create 'SickBeard/autoProcessTV/autoProcessTV.cfg from gui'
- edit protocol (http/https), port, and webroot from FreeNAS gui
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
How do I update from 0.6?

uhh, not sure abou that. What I would do for know is..
1) shutdown all the plugins from their gui
2) backup the 'data/' folder in each of the plugins folder (mv /usr/pbi/sabnzbd-amd64/data/ /usr/pbi/sabnzbd-data/)
3) uninstall the pbi from the freenas gui
4) install the new pbi from the freenas gui
5) restore 'data/' folder in each of the plugins folder (mv /usr/pbi/sabnzbd-data/* /usr/pbi/sabnzbd-amd64/data/)

I'll dig into the documentation and see if I read how freenas wants us to handle upgrades
Goodluck, to be safer use cp instead of mv above
 

Symbiot

Cadet
Joined
Jul 13, 2012
Messages
7
Being very new to freenas....

Is there a guide to installing sabnzbd & sickbeard from the previous posts links?

I just move from WHS...with some difficulty.... and want to get my old sabnzbd+sickbeard setup again.... am missing important TV-episodes :smile: :)

So a guide to installing the files and getting them running/configured would be grand!!
 
Status
Not open for further replies.
Top