Re: [systemd-devel] Installing gitlab

2014-01-24 Thread Lennart Poettering
On Thu, 23.01.14 10:51, Marwan Rabbâa (wagha...@gmail.com) wrote:

> [Install]
> WantedBy=gitlab.target
> * gitlab-unicorn.service *
> [Unit]
> Description=GitLab Unicorn Server
> 
> [Service]
> User=git
> WorkingDirectory=/var/www/gitlab
> Environment=RAILS_ENV=production
> SyslogIdentifier=gitlab-unicorn
> PIDFile=/var/run/gitlab-unicorn.pid
> 
> ExecStart=/var/www/gitlab/script/unicorn
> ExecStop=/usr/bin/kill -QUIT $MAINPID

This sounds really wrong... SIGQUIT is a signal to ask a process to
terminate and core dump. If the app is using this signal to terminate
cleanly, then that would be really confused...

Note that for most services ExecStop= is actually unnecessary to
specify, since systemd sends SIGTERM to them anyway, which is the most
common way how sservices are told to terminate anyway...

> What is wrong with my conf ?

Hmm, check syslog. Note that there's currently a race in the syslog
handling between the journal and the clients, so that messages that are
logged immediately before a service exits might nor properly be
associated with that service. There's a kernel patch pending to allow us
to fix that. In the meantime, check the full "journalctl" for those
messages...

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Installing gitlab

2014-01-23 Thread Holger Schurig
Marwan, he specified it, see above the line directly after [Service]

> [Service]
> Type=forking
> User=git
> WorkingDirectory=/var/www/gitlab
> Environment=RAILS_ENV=production

One thing that makes me wonder is however his sidekick.target thingy.
It says that Redis and Postgresql should be started, but his
sidekick.service file doesn't say this. I think that his *.target is
superfluous and should get away, and that the sidekick.service file
should declare what dependencies it has/wants.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Installing gitlab

2014-01-23 Thread Mathieu Bridon
On Thu, 2014-01-23 at 11:16 +0100, Marwan Rabbâa wrote:
> there is already Type=forking in the service section

Indeed, I got confused between your two services (the second one doesn't
have it).

And the systemctl status output says the exit code was 1, not 0, so it
has indeed nothing to do with what I said.

My apologies for not paying more attention.


-- 
Mathieu


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Installing gitlab

2014-01-23 Thread Holger Schurig
Maybe this script *needs* a tty?  Maybe it doesn't run as user "git",
e.g. wrong rights, wrong home directory?

Try to put a "set -x" at the top of the script and restart it, then
you'll see where it failed. Then, look into that program and find out
why it failed. If in doubt, pepper it with debug printf or Ruby's
equivalent.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Installing gitlab

2014-01-23 Thread Mathieu Bridon
On Thu, 2014-01-23 at 10:51 +0100, Marwan Rabbâa wrote:
> that is not very useful for me. /var/www/gitlab/script/sidekiq is just
> a litle startup script for sidekiq
> 
> #!/usr/bin/env sh
> 
> 
> cd /var/www/gitlab
> /usr/local/bin/bundle exec sidekiq -q
> post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default 
> -e production -P /var/run/gitlab-sidekiq.pid -d -L 
> /var/www/gitlab/log/sidekiq.log >> /var/www/gitlab/log/sidekiq.log 2>&1
> 
> 
> When I run this script in a tty, I have a 0 exit code, I presume it
> works (the process behind is started).

The way sidekiq is started, it forks itself as a daemon, and the parent
process exits.

Because you didn't specify the Type= option in the
gitlab-sidekiq.service file, systemd assumes the default: Type=simple

This means that systemd expects the main process to just start, and keep
running forever. (systemd handles the forking)

So when the parent process exits after forking, systemd assumes that the
service failed.

To fix this, you should use Type=forking in your gitlab-sidekiq.service
file.

I recommend you look at the systemd.service(5) manual page for more
details.


-- 
Mathieu

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Installing gitlab

2014-01-23 Thread Marwan Rabbâa
there is already *Type=forking *in the service section


2014/1/23 Mathieu Bridon 

> On Thu, 2014-01-23 at 10:51 +0100, Marwan Rabbâa wrote:
> > that is not very useful for me. /var/www/gitlab/script/sidekiq is just
> > a litle startup script for sidekiq
> > 
> > #!/usr/bin/env sh
> >
> >
> > cd /var/www/gitlab
> > /usr/local/bin/bundle exec sidekiq -q
> >
> post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default
> -e production -P /var/run/gitlab-sidekiq.pid -d -L
> /var/www/gitlab/log/sidekiq.log >> /var/www/gitlab/log/sidekiq.log 2>&1
> > 
> >
> > When I run this script in a tty, I have a 0 exit code, I presume it
> > works (the process behind is started).
>
> The way sidekiq is started, it forks itself as a daemon, and the parent
> process exits.
>
> Because you didn't specify the Type= option in the
> gitlab-sidekiq.service file, systemd assumes the default: Type=simple
>
> This means that systemd expects the main process to just start, and keep
> running forever. (systemd handles the forking)
>
> So when the parent process exits after forking, systemd assumes that the
> service failed.
>
> To fix this, you should use Type=forking in your gitlab-sidekiq.service
> file.
>
> I recommend you look at the systemd.service(5) manual page for more
> details.
>
>
> --
> Mathieu
>
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Installing gitlab

2014-01-23 Thread Marwan Rabbâa
Hi,

I want to install gitlab (sidekiq and unicorn are required) on my fresh
fedora installation.

New to systemd manager, I've some trouble install this wonderful app.

If I've understand systemd, I have to create 3 files : one per service (1
for sidekiq, 1 for unicorn, and 1 for gitlab).

* gitlab-sidekiq.service *
[[Unit]
Description=GitLab Sidekiq Worker

[Service]
Type=forking
User=git
WorkingDirectory=/var/www/gitlab
Environment=RAILS_ENV=production
SyslogIdentifier=gitlab-sidekiq
PIDFile=/var/run/gitlab-sidekiq.pid

ExecStart=/var/www/gitlab/script/sidekiq
ExecStop=/usr/local/bin/bundle exec "sidekiqctl stop
/var/run/gitlab-sidekiq.pid >> /var/www/gitlab/log/sidekiq.log 2>&1"

[Install]
WantedBy=gitlab.target
* gitlab-unicorn.service *
[Unit]
Description=GitLab Unicorn Server

[Service]
User=git
WorkingDirectory=/var/www/gitlab
Environment=RAILS_ENV=production
SyslogIdentifier=gitlab-unicorn
PIDFile=/var/run/gitlab-unicorn.pid

ExecStart=/var/www/gitlab/script/unicorn
ExecStop=/usr/bin/kill -QUIT $MAINPID
ExecReload=/usr/bin/kill -USR2 $MAINPID

[Install]
WantedBy=gitlab.target
* gitlab.target *
[Unit]
Description=GitLab - Self Hosted Git Management
Requires=redis.service postgresql.service
After=redis.service postgressql.service syslog.target network.target

[Install]
WantedBy=multi-user.target






But systemctl start gitlab-sidekiq.service crash. systemctl status
gitlab-sidekiq.service returns
*
   Loaded: loaded (/usr/lib/systemd/system/gitlab-sidekiq.service; disabled)
   Active: failed (Result: exit-code) since jeu. 2014-01-23 10:48:43 CET;
6s ago
  Process: 6987 ExecStart=/var/www/gitlab/script/sidekiq (code=exited,
status=1/FAILURE)

janv. 23 10:48:42 localhost.localdomain systemd[1]: Starting GitLab Sidekiq
Worker...
janv. 23 10:48:43 localhost.localdomain systemd[1]: gitlab-sidekiq.service:
control process exited, code=exited status=1
janv. 23 10:48:43 localhost.localdomain systemd[1]: Failed to start GitLab
Sidekiq Worker.
janv. 23 10:48:43 localhost.localdomain systemd[1]: Unit
gitlab-sidekiq.service entered failed state.
*

that is not very useful for me. /var/www/gitlab/script/sidekiq is just a
litle startup script for sidekiq

#!/usr/bin/env sh

cd /var/www/gitlab
/usr/local/bin/bundle exec sidekiq -q
post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default
-e production -P /var/run/gitlab-sidekiq.pid -d -L
/var/www/gitlab/log/sidekiq.log >> /var/www/gitlab/log/sidekiq.log 2>&1


When I run this script in a tty, I have a 0 exit code, I presume it works
(the process behind is started).

What is wrong with my conf ?

Regards,
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel