Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Popfile - a couple of minor tweaks...
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
lyallp
Veteran
Veteran


Joined: 15 Jul 2004
Posts: 1403
Location: Adelaide/Australia

PostPosted: Sat Sep 13, 2008 11:37 am    Post subject: Popfile - a couple of minor tweaks... Reply with quote

Since the upgrade of Popfile, I have had to re-instigate a couple of tweaks to the popfile source.

I thought I might share these.

1. Popfile uses a large amount of CPU, when doing nothing - well, not 50% of cpu, but it is constantly using CPU.

To fix this, edit POPfile/Loader.pm line 698 (or thereabouts) to increase sleep time.

Code:
        select(undef, undef, undef, 0.05) if !$nowait;


to

Code:
        select(undef, undef, undef, 1) if !$nowait;



2. Popfile startup at boot time.

I created the following /etc/init.d/popfile script a while ago, it appears to not have been overwritten, so it may be useful to others.

Code:
#!/sbin/runscript
# Copyright 1999-2004 Lyall Pearce
# Distributed under the terms of the GNU General Public License v2
# Constructed by Lyall Pearce, 2004

# Note: You need to start popfile on boot

depend() {
        need net
}

start() {
        ebegin "Starting popfile"
        start-stop-daemon --start --quiet --background --env POPFILE_ROOT="${POPFILE_ROOT}" --exec "${POPFILE_ROOT}/popfile.pl"
        eend $?
}

stop() {
        ebegin "Stopping popfile"
        start-stop-daemon --stop --verbose --name ${POPFILE_ROOT}/popfile.pl
        eend $?
}


This requires /etc/conf.d/popfile to contain
Code:

POPFILE_ROOT=/usr/share/popfile
POPFILE_USER=/usr/share/popfile


and a final change to popfile itself, as the start-stop-daemon does not allow multiple --env options
Edit /usr/share/popfile/POPFile/Configuration.pm, changing
Code:

    # Local copies of POPFILE_ROOT and POPFILE_USER

    $self->{popfile_root__} = $ENV{POPFILE_ROOT} || './';
    $self->{popfile_user__} = $ENV{POPFILE_USER} || './';

to
Code:

    # Local copies of POPFILE_ROOT and POPFILE_USER
    # Hacked by Lyall Pearce to make POPFILE_USER default to POPFILE_ROOT if not found

    $self->{popfile_root__} = $ENV{POPFILE_ROOT} || './';
    $self->{popfile_user__} = $ENV{POPFILE_USER} || $ENV{POPFILE_ROOT} || './';

_________________
...Lyall
Back to top
View user's profile Send private message
wjb
Guru
Guru


Joined: 10 Jul 2005
Posts: 406
Location: Fife, Scotland

PostPosted: Sat Sep 13, 2008 9:11 pm    Post subject: Reply with quote

I do something vaguely similar except I run a tweaked /usr/sbin/popfile from my service. I changed the last line of /usr/sbin/popfile from
Code:

exec ./$POPFILE_PL

to
Code:

./$POPFILE_PL --set pop3_port=7999

(I have courier running and that has port 110, so I till I did this I couldn't get into the popfile web interface to change it because popfile wouldn't run since it couldn't have 110. And the exec goes otherwise the service exits immediately)

I'll give the sleep change a go when I update to the new version of popfile.

What does the --env do? Is it equivalent to the way that /usr/sbin/popfile sets the current working directory before calling popfile.pl?
Back to top
View user's profile Send private message
lyallp
Veteran
Veteran


Joined: 15 Jul 2004
Posts: 1403
Location: Adelaide/Australia

PostPosted: Sun Sep 14, 2008 12:00 am    Post subject: Reply with quote

Popfile has 2 env vars, POPFILE_ROOT where it expects to find the program itself (/usr/share/popfile) and POPFILE_USER where it expects to find the database and config files.

Since I have been using Popfile since early days, my config and database are in the /usr/share/popfile directory, rather than /var/.
So, for my purposes, having POPFILE_ROOT == POPFILE_USER is ok.

If you don't set POPFILE_USER on startup, it defaults to root (/) - which is not where my stuff is, hence, the change to make it default to POPFILE_ROOT.

You cannot supply POPFILE_USER on the start-stop-daemon line as start-stop-daemon does not allow 2 --env options.

By the way, you can configure the web port by editing /usr/share/popfile/popfile.cfg or by using the web interface.
_________________
...Lyall
Back to top
View user's profile Send private message
wjb
Guru
Guru


Joined: 10 Jul 2005
Posts: 406
Location: Fife, Scotland

PostPosted: Wed Sep 17, 2008 11:52 pm    Post subject: Reply with quote

(Been busy for a while)

lyallp wrote:
...

By the way, you can configure the web port by editing /usr/share/popfile/popfile.cfg or by using the web interface.


Yes but the web interface is only available once you have the thing running, however its truly odd that I failed to realise that the port number was in the cfg because I'd modified that file for a different reason. Awake, not.

Anyway, I've left things as they were for me - so I'm still using /usr/sbin/popfile as the body of the service, with the last line hacked to remove the exec.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum