ssh keys poller

52 views
Skip to first unread message

Martin Pettersson

unread,
Jun 22, 2009, 8:35:23 AM6/22/09
to gitorious
Dear all
If I run poller from the command line everything works fine. I have chosen to run it under daemontools and it seems to work with everything except when I register a new ssh key. It never get rid of the red mark. I can create new reositories without problems.


I get this in the message_processing.log:


SshKeyProcessor consuming message. Command: delete_from_authorized_keys. Arguments: ["### START KEY 13 ###\ncommand=\"gitorious martin\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa xxxxxxxxxxxxxxxxxxx== SshKey:13-User:1\n### END KEY 13 ###\n"]. Target_id:
Processor:process! - error in on_error, will propagate no further: 501 #5.1.1 bad address


here is the poller/run file used by daemontools
#!/bin/sh
exec 2>&1
USER=git
exec setuidgid $USER /var/www/gitorious/script/poller run


Does anybody have any idea where to start digging?


Thanks and best regards
Martin

Johan Sørensen

unread,
Jun 22, 2009, 8:40:18 AM6/22/09
to gito...@googlegroups.com
On Mon, Jun 22, 2009 at 2:35 PM, Martin Pettersson<mar...@siamect.com> wrote:
> Dear all
> If I run poller from the command line everything works fine. I have chosen
> to run it under daemontools and it seems to work with everything except when
> I register a new ssh key. It never get rid of the red mark. I can create new
> reositories without problems.
>
> I get this in the message_processing.log:
>
> SshKeyProcessor consuming message. Command: delete_from_authorized_keys.
> Arguments: ["### START KEY 13 ###\ncommand=\"gitorious
> martin\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty
> ssh-rsa xxxxxxxxxxxxxxxxxxx== SshKey:13-User:1\n### END KEY 13 ###\n"].
> Target_id:
> Processor:process! - error in on_error, will propagate no further: 501
> #5.1.1 bad address

That error sounds a lot like a SMTP error. It tries to send you an
email whenever the processor fail, using the
`exception_notification_emails` config in gitorious.yml, which should
be formatted as a YAML array, eg:
exception_notification_emails:
- y...@somewhere.com

But if you backtrack a little in the logfile you should see the original error

JS

Martin Pettersson

unread,
Jun 22, 2009, 10:05:29 AM6/22/09
to gito...@googlegroups.com
Thanks for your quick response.
I fixed the email address and the email message I get is very much the same info as in the log file. As the email doesn't cause any problems there are now additional info in the file. Seems to be a problem with the environment stuff...
I thought I got the same environment by using the setuidgid $USER but this is ofcource not a gitorious problem but more related to me being such a newbie on the daemontools stuff.


Thanks very much for your help




[Gitorious Processor] fail in SshKeyProcessor
(Mon Jun 22 20:35:57 2009)
An exception occured in #<SshKeyProcessor:0xb1b36d0
@message=
#<Stomp::Message:0xb1cd508
@body=
"{\"target_class\": \"SshKey\", \"command\": \"add_to_authorized_keys\", \"arguments\": [\"### START KEY 20 ###\\ncommand=\\\"gitorious martin\\\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa xxxxxxxxxx== SshKey:20-User:1\\n### END KEY 20 ###\\n\"], \"target_id\": 20, \"identifier\": \"ssh_key_20\"}",
@command="MESSAGE",
@headers=
{"content-type"=>"text/plain; charset=UTF-8",
"message-id"=>"ID:MATACILT-42064-1245665695431-4:23:-1:1:1",
"destination"=>"/queue/GitoriousSshKeys",
"timestamp"=>"1245677757101",
"expires"=>"0",
"subscription"=>"ssh_key_processor",
"content-length"=>"661",
"priority"=>"0"}>>
!


{"target_class": "SshKey", "command": "add_to_authorized_keys", "arguments": ["### START KEY 20 ###\ncommand=\"gitorious martin\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx== SshKey:20-User:1\n### END KEY 20 ###\n"], "target_id": 20, "identifier": "ssh_key_20"}


ArgumentError: couldn't find HOME environment -- expanding `~'


/var/www/gitorious/app/models/ssh_key_file.rb:49:in `expand_path'
/var/www/gitorious/app/models/ssh_key_file.rb:49:in `default_authorized_keys_path'
/var/www/gitorious/app/models/ssh_key_file.rb:24:in `initialize'
/var/www/gitorious/app/models/ssh_key.rb:63:in `new'
/var/www/gitorious/app/models/ssh_key.rb:63:in `add_to_authorized_keys'
/var/www/gitorious/app/processors/ssh_key_processor.rb:27:in `on_message'
/var/www/gitorious/vendor/plugins/activemessaging/lib/activemessaging/processor.rb:32:in `process!'
/var/www/gitorious/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:229:in `block (2 levels) in _dispatch'
/var/www/gitorious/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:149:in `execute_filter_chain'
/var/www/gitorious/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:228:in `block in _dispatch'
/var/www/gitorious/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:219:in `each'
/var/www/gitorious/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:219:in `_dispatch'
/var/www/gitorious/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:200:in `block in dispatch'
<internal:prelude>:8:in `synchronize'
/var/www/gitorious/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:197:in `dispatch'
/var/www/gitorious/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:43:in `block (2 levels) in start'

Johan Sørensen

unread,
Jun 22, 2009, 10:09:48 AM6/22/09
to gito...@googlegroups.com
On Mon, Jun 22, 2009 at 4:05 PM, Martin Pettersson<mar...@siamect.com> wrote:
> I fixed the email address and the email message I get is very much the same
> info as in the log file. As the email doesn't cause any problems there are
> now additional info in the file. Seems to be a problem with the environment
> stuff...
> I thought I got the same environment by using the setuidgid $USER but this
> is ofcource not a gitorious problem but more related to me being such a
> newbie on the daemontools stuff.
[snip]

> ArgumentError: couldn't find HOME environment -- expanding `~'

Yeah, passing along a HOME env variable as well to daemontools is
probably enough here:
$ env HOME=/tmp ruby -e "puts File.expand_path('~')"
/tmp

Would you mind sharing your daemontools setup once you're done
(perhaps on the Gitorious wiki)? I've been asked a few times about it,
but don't use it myself so would be nice to just be able to refer to
it.

Cheers,
JS

Martin Pettersson

unread,
Jun 22, 2009, 11:26:47 AM6/22/09
to gito...@googlegroups.com
It works now...
Ofcourse I will give you the setup... I will install the same at work and try to write it down in an understandable way... So maybe expect something end of the week...


Anyway here is the non-verbose edition of how to make environmental variable HOME in daemontools:


The run-file looks like this:
------------------------------------------------------------------------------------------
#!/bin/bash
exec 2>&1
USER=git
exec setuidgid $USER envdir ./env /var/www/gitorious/script/poller run
------------------------------------------------------------------------------------------
You need to create the .env dir:
cd /home/git/service/poller
sudo mkdir ./env
ls
env log run supervise


The HOME env variable is declared in a file with the same name:
echo '/home/git' > ./env/HOME


get the service restarted:
sudo svc -d /etc/service/poller
sudo svc -u /etc/service/poller


---------------------------------------------------------------------------------------
works! (at least for me)


I have also put a
svc -t /etc/service/poller
in the crontab once per hour...
kills the poller and deamontools restarts it immediately again.
My server is not used much and I think the poller looses the connection to the sql server after a while on no activity... not sure but it usually stops working after long time... and this line in the crontab cures it...
Maybe it is not needed anymore. I saw some correspondence about it?


Thanks and good night.
Martin

Martin Pettersson

unread,
Jun 23, 2009, 10:24:13 AM6/23/09
to gito...@googlegroups.com
Hmmm
How do I create a new page on the wiki?
Anyway here is a first edition of the verbose version on daemontools:


Thanks a lot for you help...


#Short description how I successfully set up daemontools#
to handle:


1. activemq
2. poller
3. git-daemon


I did it on Ubuntu Jaunty server edition at work and also Kubuntu Jaunty on my laptop.


Maybe I will try to handle the UltraSphinx daemon too, but for some reason I haven't done that yet.


Craig Websters words from 2008-12-13 13:34 helped me a lot:
http://barkingiguana.com/2008/11/28/running-daemontools-under-ubuntu-810

Should be said that I don't know the proper size of softlimits and stuff...
Just copied it from http://barkingiguana.com/2008/11/28/running-daemontools-under-ubuntu-810


Daemontools supervises the daemons and restarts them in case they die.
You have to set up the daemon and also the log for it so you can see if anything goes wrong...



**************************************
************** activemq **************
**************************************


sudo adduser --system activemq
sudo chown -R activemq /usr/local/apache-activemq-5.2.0/data
sudo mkdir -p /usr/local/apache-activemq-5.2.0/service/activemq/{,log,log/main}


sudo nano /usr/local/apache-activemq-5.2.0/service/activemq/run


#!/bin/sh
exec 2>&1


USER=activemq


exec softlimit -m 1073741824 \
setuidgid $USER \
/usr/local/apache-activemq-5.2.0/bin/activemq



******************************************
************** activemq log **************
******************************************


sudo nano /usr/local/apache-activemq-5.2.0/service/activemq/log/run


#!/bin/sh
USER=activemq
exec setuidgid $USER multilog t s1000000 n10 ./main


***********************************************************************
************** activemq rights, ownership and soft-links **************
***********************************************************************


sudo sh -c "find /usr/local/apache-activemq-5.2.0/service/activemq -name 'run' |xargs chmod +x,go-wr"
sudo chown activemq /usr/local/apache-activemq-5.2.0/service/activemq/log/main
sudo ln -s /usr/local/apache-activemq-5.2.0/service/activemq /etc/service/activemq


sudo svc -u /etc/service/activemq


Tail the logs to make sure everything is happening as you'd expect.


sudo tail -F /etc/service/activemq/log/main/current



************************************
************** poller **************
************************************


sudo mkdir -p /home/git/service/poller/{,log,log/main}


sudo nano /home/git/service/poller/run


#!/bin/sh
exec 2>&1


USER=git


#exec softlimit -m 1073741824 \
#setuidgid $USER \
#/var/www/gitorious/script/poller run
#to get the HOME env variable to work I changed to
exec setuidgid $USER envdir ./env /var/www/gitorious/script/poller run



****************************************
************** poller log **************
****************************************


sudo nano /home/git/service/poller/log/run


#!/bin/sh
USER=git
exec setuidgid $USER multilog t s1000000 n10 ./main



*********************************************************************
************** poller rights, ownership and soft-links **************
*********************************************************************



sudo sh -c "find /home/git/service/poller -name 'run' |xargs chmod +x,go-wr"
sudo chown git /home/git/service/poller/log/main
sudo ln -s /home/git/service/poller /etc/service/poller


sudo svc -u /etc/service/poller


Tail the logs to make sure everything is happening as you'd expect.


sudo tail -F /etc/service/poller/log/main/current



****************************************
************** git-daemon **************
****************************************


sudo mkdir -p /home/git/service/git-daemon/{,log,log/main}


sudo nano /home/git/service/git-daemon/run


#!/bin/sh
exec 2>&1


USER=git


exec softlimit -m 1073741824 \
setuidgid $USER \
/var/www/gitorious/script/git-daemon run



********************************************
************** git-daemon log **************
********************************************


sudo nano /home/git/service/git-daemon/log/run


#!/bin/sh
USER=git
exec setuidgid $USER multilog t s1000000 n10 ./main


*************************************************************************
************** git-daemon rights, ownership and soft-links **************
*************************************************************************


sudo sh -c "find /home/git/service/git-daemon -name 'run' |xargs chmod +x,go-wr"
sudo chown git /home/git/service/git-daemon/log/main
sudo ln -s /home/git/service/git-daemon /etc/service/git-daemon


sudo svc -u /etc/service/git-daemon


Tail the logs to make sure everything is happening as you'd expect.


sudo tail -F /etc/service/git-daemon/log/main/current
***************************************************************
Beginning to see a pattern here?


Should be said that I don't know the proper size of the softlimits and stuff...
Just copied it from http://barkingiguana.com/2008/12/13/deploying-activemq-on-ubuntu-810



I have also put a
svc -t /etc/service/poller
in the crontab once per hour...
It kills the poller. Daemontools restarts it immediately again.


My server is not used much and I think the poller looses the connection to the
mysql server after a while with no activity... not sure but it usually stops working
after long time... and this line in the crontab cures it...
Maybe it is not needed anymore. I think there are some correspondence about it?


Thanks and best regards
Martin




On Monday 22 June 2009 09:09:48 pm Johan Sørensen wrote:

Martin Pettersson

unread,
Jun 23, 2009, 11:48:28 AM6/23/09
to gito...@googlegroups.com
New page .. is it just to make a[[link]] and then click on that one and edit?... I get "invalid page, badly formatted title or body"
This is the same both on my private server and on gitorious.org


Thanks
Martin

Johan Sørensen

unread,
Jun 23, 2009, 11:51:23 AM6/23/09
to gito...@googlegroups.com
On Tue, Jun 23, 2009 at 5:48 PM, Martin Pettersson<mar...@siamect.com> wrote:
> New page .. is it just to make a[[link]] and then click on that one and
> edit?... I get "invalid page, badly formatted title or body"
> This is the same both on my private server and on gitorious.org

Yes, or you can go to
http://gitorious.org/gitorious/pages/SomePageName (replace
SomePageName with whatever the page title should be) and it should
redirect to the create/edit page (if you're logged in).

This doesn't work for you? if so, what's the name of the page you're
trying to create and I can see if I figure out why..

>
> Thanks
> Martin

JS

Martin Pettersson

unread,
Jun 23, 2009, 11:59:45 AM6/23/09
to gito...@googlegroups.com
Hi
Seems like this works: http://localhost/test3/pages/Flump
but not this http://localhost/test3/pages/flump


Capital first char in the last part then it works but if it is lowercase then I get that error...
Thanks

Martin Pettersson

unread,
Jun 23, 2009, 12:23:55 PM6/23/09
to gito...@googlegroups.com

Johan Sørensen

unread,
Jun 24, 2009, 4:08:34 AM6/24/09
to gito...@googlegroups.com
On Tue, Jun 23, 2009 at 6:23 PM, Martin Pettersson<mar...@siamect.com> wrote:
> Now it's there:
>
> http://gitorious.org/gitorious/pages/DaemonTools

Wonderful :)

>
> Martin

JS
Reply all
Reply to author
Forward
0 new messages