[systemd-devel] Fwd: Is this list still active? Where can I get basic help with systemd

Doug Snyder webcoach101 at gmail.com
Tue Dec 5 22:46:11 UTC 2017


---------- Forwarded message ----------
From: Doug Snyder <webcoach101 at gmail.com>
Date: Tue, Dec 5, 2017 at 5:42 PM
Subject: Re: [systemd-devel] Is this list still active? Where can I get
basic help with systemd
To: Doug Snyder <webcoach101 at gmail.com>


*Andrei, *
*yes I did try to their solution and the reason I claimed that it didn't
work is because it doesn't*
*Of course thats the first thing I tried and it fails because It doesn't
reference the variables in the config file.*
*I tried to take mostly the same code without the config file since it
wasn't working*
*That caused problems above since I had an %I in my service file and I was
told that this was because I wasn't using a template*
*( with no further explanation or any documentation  I can see on
freedesktop.org <http://freedesktop.org> )*
*I assumed maybe the fact that I wasn't using a template was why the
variables being templated from the config file weren't being resolved,*
*but asked for further clarification ...*
*but really how would I know?*
*The problem seems to be rooted in the fact that I'm not a Linux
enthusiast, I'm a data scientist that needs to run a simple task queue*
*but none of the instructions I find work.*
*Its true I've modified the ExecStart command from the example the celery
docs give.*
*I used the command that's listed in different part of the documentation to
run the task queue.*
*The command works fine in the command line, so I thought it would work
when run by systemd*
*I said that clearly in my first post.*
*As far as I know I'm trying to just get systemd to run a command at start
up in its own process*
*If that's not how things work, I'd like to know about it*
*That's why I'm here ... to learn how systemd works*
*I tried to learn about templates myself
here: https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files
<https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files>*
*and found something useful about forking untis which seems to be relevant:*
*For forking services you are supposed to define the PIDFile:*

   - PIDFile=: If the service type is marked as "forking", this directive
   is used to set the path of the file that should contain the process ID
   number of the main child that should be monitored.

*celery's docs service does have that defined and mine doesn't.*
*But they have it defined in the Environment file using %n to define the
pid file*

# %n will be replaced with the first part of the nodename.

CELERYD_PID_FILE="/var/run/celery/%n.pid"

I can't do that without using templates apparently, so I'm not sure if I
can accomplish the same thing without getting a template working
and if I should get the first part of the nodename some other way or I
should try to get the templating working.
I'm assuming that the node name is the celery node not the systemd node ...
or is there something in systemd called a node?
Assuming this is a celery defined variable %n, how is it defined in the
envirnment file. I just see it being referenced.
How are these variables defined in systemd templates?


On Tue, Dec 5, 2017 at 2:19 PM, Doug Snyder <webcoach101 at gmail.com> wrote:

> Well, it runs fine by itself using the exact same command on the command
> line.
> Its when systemd is added to the mix that the problems occur
> The people that put out celery have docs on how to use it with systemd,
> its just that they don't work:
> http://docs.celeryproject.org/en/latest/userguide/daemonizing.html
> I based my service off theirs but the Type=forking was copied right from
> theirs
> Maybe if I use their version more exactly it might work.
> But their version doesn't work at all ssince I suspect they are using
> templating
> ( I copied the %I from their file )
> They reference config variables in their template:
>
> /etc/systemd/system/celery.service:
>
> [Unit]Description=Celery ServiceAfter=network.target
> [Service]Type=forkingUser=celeryGroup=celeryEnvironmentFile=-/etc/conf.d/celeryWorkingDirectory=/opt/celeryExecStart=/bin/sh -c '${CELERY_BIN} multi start ${CELERYD_NODES} \  -A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \  --logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}'ExecStop=/bin/sh -c '${CELERY_BIN} multi stopwait ${CELERYD_NODES} \  --pidfile=${CELERYD_PID_FILE}'ExecReload=/bin/sh -c '${CELERY_BIN} multi restart ${CELERYD_NODES} \  -A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \  --logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}'
> [Install]WantedBy=multi-user.target
>
> /etc/default/celeryd:
>
> # Names of nodes to start#   most people will only start one node:CELERYD_NODES="worker1"#   but you can also start multiple and configure settings#   for each in CELERYD_OPTS#CELERYD_NODES="worker1 worker2 worker3"#   alternatively, you can specify the number of nodes to start:#CELERYD_NODES=10
> # Absolute or relative path to the 'celery' command:CELERY_BIN="/usr/local/bin/celery"#CELERY_BIN="/virtualenvs/def/bin/celery"
> # App instance to use# comment out this line if you don't use an appCELERY_APP="proj"# or fully qualified:#CELERY_APP="proj.tasks:app"
> # Where to chdir at start.CELERYD_CHDIR="/opt/Myproject/"
> # Extra command-line arguments to the workerCELERYD_OPTS="--time-limit=300 --concurrency=8"# Configure node-specific settings by appending node name to arguments:#CELERYD_OPTS="--time-limit=300 -c 8 -c:worker2 4 -c:worker3 2 -Ofair:worker1"
> # Set logging level to DEBUG#CELERYD_LOG_LEVEL="DEBUG"
> # %n will be replaced with the first part of the nodename.CELERYD_LOG_FILE="/var/log/celery/%n%I.log"CELERYD_PID_FILE="/var/run/celery/%n.pid"
> # Workers should run as an unprivileged user.#   You need to create this user manually (or you can choose#   a user/group combination that already exists (e.g., nobody).CELERYD_USER="celery"CELERYD_GROUP="celery"
> # If enabled pid and log directories will be created if missing,# and owned by the userid/group configured.CELERY_CREATE_DIRS=1
>
> But nowhere in their documentation is any mention of the fact that they are using templates or how how make a service a template.
>
>  Is there docs on this you can point me to? Or if not just explain it?
>
>
>
> On Tue, Dec 5, 2017 at 1:50 PM, Lennart Poettering <lennart at poettering.net
> > wrote:
>
>> On Di, 05.12.17 13:33, Doug Snyder (webcoach101 at gmail.com) wrote:
>>
>> > Getting rid of the template syntax changed the behavior but now it
>> appears
>> > there's another problem I don't understand.
>> > it tries to start the unit and it shows some encouraging signs but fails
>> > because a timeout was exceeded.
>> > Celery starts and shows healthy output but then sends a SIGCHLD and then
>> > dies
>>
>> Uh, I am not sure what celery is, but if celery is started but exits
>> on its own then I am not sure I can help you very much.
>>
>> > I don't know if you know what celery is but its a task queue so it does
>> > create child processes
>> > I thought the Type=forking line in the service unit would let systemd
>> about
>> > that.
>> > Or maybe its dying for some other reason?
>> > It works fine when run without systemd
>>
>> Does it detach on its own? i.e. double fork? if yes, then type=forking
>> is the right choice, otherwise you need a different Type=.
>>
>> > I don't think I can send you detailed output until we get this issue
>> > resolved with the mailing list and why its not excepting emails with
>> debug
>> > output.
>> > Short emails seem to post. Long ones don't. There's no indication of
>> whats
>> > going on
>>
>> There are message size limits on this mailing list. Please condense
>> your logs to only include relevant bits hence, or use fpaste.org or
>> something like that, and drop the URL.
>>
>> Lennart
>>
>> --
>> Lennart Poettering, Red Hat
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20171205/beffcfd5/attachment-0001.html>


More information about the systemd-devel mailing list