Re: [systemd-devel] Systemd -- Using Environment variable in a Unit file from Environment File
Guys, Any suggestions about this kind of problem ? -- Regards, Raghavendra. H. R (Raghu) On Fri, May 26, 2017 at 3:06 PM, Raghavendra. H. R wrote: > Hi All, > > I'm in the situation where path of my server changes due to version > change. I don't want to modify my systemd unit file everytime, instead I > want to go ahead with my environement file for modification. > > My Env file system.env contains environment variables > > system.env > > SERVER_PATH=/home/raghu/TAP/server/V110 > > In my systemd unit file I have included this enviroment file. > > Tap.service > > [Unit] > Description=Starting TAP server > > [Service] > EnvironmentFile=/home/raghu/system.env > *WorkingDirectory=${SERVER_PATH}* > *ExecStart=/home/raghu/TAP/out "./server.js"* > > [Install] > WantedBy=multi-user.target > > I'm stuck with the below error > > *error: Cannot find module '/server.js'* > > ${SERVER_PATH} is not set to my WorkingDirectory. Instead of using this > variable, if I give the absolute path, my unit file works well. > > Need help in resoling this issue. > > -- > Regards, > > Raghavendra. H. R > (Raghu) > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] Systemd -- Using Environment variable in a Unit file from Environment File
Hi All, I'm in the situation where path of my server changes due to version change. I don't want to modify my systemd unit file everytime, instead I want to go ahead with my environement file for modification. My Env file system.env contains environment variables system.env SERVER_PATH=/home/raghu/TAP/server/V110 In my systemd unit file I have included this enviroment file. Tap.service [Unit] Description=Starting TAP server [Service] EnvironmentFile=/home/raghu/system.env *WorkingDirectory=${SERVER_PATH}* *ExecStart=/home/raghu/TAP/out "./server.js"* [Install] WantedBy=multi-user.target I'm stuck with the below error *error: Cannot find module '/server.js'* ${SERVER_PATH} is not set to my WorkingDirectory. Instead of using this variable, if I give the absolute path, my unit file works well. Need help in resoling this issue. -- Regards, Raghavendra. H. R (Raghu) ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] Having synchronization between 2 process using systemd.
Hi All, I have a scenario in which I have 2 processes and both acts as Server & Client. Process A starts it server & tries to connect as client with Process B. Process B starts it server & tries to connect as client with Process A. We want handle this kind of scenario with the help of systemd sd_notify or with the help of runlevels or any other mechanism. Kindly share some needful inputs whether it is possible in systemd. We dont want to get add delay in any process. -- Regards, Raghavendra. H. R (Raghu) ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] Multiple notifications using sd_notify
Hi All, Can we use sd_notify multiple times in any application to which can be used as notification for other processes. If Process B & C both depends & need notification from Process A. Can we use sd_notify in Process A multiple times which can be used other processes at different times ? -- Regards, Raghavendra. H. R (Raghu) ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Query regarding NOTIFY_SOCKET
Does it mean that only services can notify systemd about their readiness and systemd will not notify another service. sd_notify call from *Myapp *of one.service is returning value '1'. So one.service has successfully notified systemd that it is READY. *But I observe second.service is not starting. I have given NotifyAccess=all in one.service.* One.service *[Unit]* *Description=one Sd_notify example* *Before=second.service* *[Service]* *Type=notify* *NotifyAccess=all* *ExecStart=/etc/Myapp* *[Install]* *WantedBy=multi-user.target* *Second.service* *=* *[Unit]* *Description=Second Sd_notify example* *After=one.service* *[Service]* *ExecStart=/etc/Second_Myapp* *[Install]* *WantedBy=multi-user.target* I dont see second.service starting after sd_notify is done from one.service. Regards, Raghavendra H R -- Regards, Raghavendra. H. R (Raghu) On Tue, Nov 8, 2016 at 7:47 PM, Alessandro Puccetti wrote: > I do not understand the relation between your question and service > dependencies (e.g. Requires= and After= directives). > > Second is started when all the required services are ready, because of > "Requires=one.service" second will be started after one's status is READY. > Because one is Type=notify this state is not reached until one executes > sd_notify(...). > > > On Tue, Nov 8, 2016 at 2:59 PM, Raghavendra. H. R > wrote: > >> Just one last question. >> Does systemd notifies other services based on this notification ? >> > > In this case are the services to notify systemd not vice-versa and > notifications are accepted by systemd for a specific service the depending > on the value of Type= and NotifyAccess=. > >> >> I have 2 service files, application in one service file sends >> notification using sd_notify does systemd starts another service file. >> >> one.service >> >> *[Unit]* >> *Description=Sd_notify example* >> *Before=second.service* >> >> *[Service]* >> *Type=notify* >> *ExecStart=/etc/Myapp* >> > As I said before you may need to add "NotifyAccess=all" here. > >> >> *[Install]* >> *WantedBy=multi-user.target* >> >> second.service >> == >> *[Unit]* >> *Description=Second sd_notify example* >> *Requires=**one.service* >> *After=one.service* >> >> *[Service]* >> *ExecStart=/etc/SecondApp* >> >> *[Install]* >> *WantedBy=multi-user.target* >> >> >> >> *Regards,* >> *Raghavendra H R* >> >> -- >> Regards, >> >> Raghavendra. H. R >> (Raghu) >> >> On Tue, Nov 8, 2016 at 7:14 PM, Alessandro Puccetti < >> alessan...@kinvolk.io> wrote: >> >>> >>> >>> On Tue, Nov 8, 2016 at 2:28 PM, Raghavendra. H. R >>> wrote: >>> >>>> Hi Tomasz, >>>> >>>> Thanks for pointing out the mistake. I actually missed the line >>>> "Type=notify" in the mail. >>>> I found the journalctl logs and from that I can make out the real >>>> problem is not about NOTIFY_SOCKET. It is about child process in my >>>> application *Myapp.* >>>> >>>> Below given is my Service file. >>>> >>>> *[Unit]* >>>> *Description=Sd_notify example* >>>> >>>> *[Service]* >>>> *Type=notify* >>>> *ExecStart=/etc/Myapp* >>>> >>>> *[Install]* >>>> *WantedBy=multi-user.target* >>>> >>>> And in Myapp code my application is using fork() to create a child >>>> process. Because of which notification is not working correctly. >>>> >>>> This is error log >>>> >>>> >>>> *localhost systemd[1]: sd_example.service: Got notification message >>>> from PID 1270, but reception only permitted for main PID 1106* >>>> >>>> Is there any way from which we can force sd_notify to make use of >>>> Parent PID instead of child process. My sd_notify is after the fork() call, >>>> so I doubt sd_notify is called from child process. >>>> >>>> MyApp code snippet >>>> >>>> *int count = 0;* >>>> *cpid = fork();* >>>> >>>> *if (cpid < 0)* >>>> *{* >>>> *printf("vfork failed.");* >>>> *}* >>>> >>>> *if (cpid == 0)* >>>> *{* >>>> *count++;* >>>> *i
Re: [systemd-devel] Query regarding NOTIFY_SOCKET
Just one last question. Does systemd notifies other services based on this notification ? I have 2 service files, application in one service file sends notification using sd_notify does systemd starts another service file. one.service *[Unit]* *Description=Sd_notify example* *Before=second.service* *[Service]* *Type=notify* *ExecStart=/etc/Myapp* *[Install]* *WantedBy=multi-user.target* second.service == *[Unit]* *Description=Second sd_notify example* *Requires=**one.service* *After=one.service* *[Service]* *ExecStart=/etc/SecondApp* *[Install]* *WantedBy=multi-user.target* *Regards,* *Raghavendra H R* -- Regards, Raghavendra. H. R (Raghu) On Tue, Nov 8, 2016 at 7:14 PM, Alessandro Puccetti wrote: > > > On Tue, Nov 8, 2016 at 2:28 PM, Raghavendra. H. R > wrote: > >> Hi Tomasz, >> >> Thanks for pointing out the mistake. I actually missed the line >> "Type=notify" in the mail. >> I found the journalctl logs and from that I can make out the real problem >> is not about NOTIFY_SOCKET. It is about child process in my application >> *Myapp.* >> >> Below given is my Service file. >> >> *[Unit]* >> *Description=Sd_notify example* >> >> *[Service]* >> *Type=notify* >> *ExecStart=/etc/Myapp* >> >> *[Install]* >> *WantedBy=multi-user.target* >> >> And in Myapp code my application is using fork() to create a child >> process. Because of which notification is not working correctly. >> >> This is error log >> >> >> *localhost systemd[1]: sd_example.service: Got notification message from >> PID 1270, but reception only permitted for main PID 1106* >> >> Is there any way from which we can force sd_notify to make use of Parent >> PID instead of child process. My sd_notify is after the fork() call, so I >> doubt sd_notify is called from child process. >> >> MyApp code snippet >> >> *int count = 0;* >> *cpid = fork();* >> >> *if (cpid < 0)* >> *{* >> *printf("vfork failed.");* >> *}* >> >> *if (cpid == 0)* >> *{* >> *count++;* >> *if(count == 1)* >> * {* >> > This notificaiton is done by the child process, but notificaitons are > accepted by default only form the main process. Read doc aobut > "NotifyAccess=". https://www.freedesktop.org/software/ > systemd/man/systemd.service.html#NotifyAccess= > >> * ret = sd_notify(0, "READY=1");* >> * printf("Return value = %d \n");* >> * }* >> * }* >> >> >> Regards, >> Raghavendra H R >> >> -- >> Regards, >> >> Raghavendra. H. R >> (Raghu) >> >> On Tue, Nov 8, 2016 at 5:15 PM, Tomasz Torcz >> wrote: >> >>> On Tue, Nov 08, 2016 at 05:01:59PM +0530, Raghavendra. H. R wrote: >>> > Hi All, >>> > >>> > I'm a newbie in Systemd init system and I'm exploring sd_notify which >>> is >>> > basically used for notification purpose in SystemD. >>> >>> It is written “systemd” (all lowercase). >>> >>> > I have created one unit file which is of type "notify" and in my >>> > application I have written sd_notify(0, "READY=1"); from which SystemD >>> can >>> > be notified that my process in totally up and running. >>> > >>> > Below given is my Service file. >>> > >>> > *[Unit]* >>> > *Description=Sd_notify example* >>> > >>> > *[Service]* >>> > *ExecStart=/etc/Myapp* >>> >>> >>> This is not 'unit of type notify'. This is unit of type 'simple'. >>> Please read "man systemd.service" and paragraph Type= and choose >>> correctly. >>> >>> >>> > Need help in understanding what value should be set in the environment >>> > varaible NOTIFY_SOCKET. >>> > But there's no much information/documentation available on >>> NOTIFY_SOCKET. >>> >>> NOTIFY_SOCKET is filled-in by systemd and it is available when you >>> correctly defined unit type. If you want to check it's value, you can >>> user getenv() inside you program and print the value. >>> I think amount of documentation about NOTIFY_SOCKET is enough, if >>> you think there's something specific missing, let us know. >>> >>> >>> -- >>> Tomasz Torcz "Never underestimate the bandwidth of a >>> station >>> xmpp: zdzich...@chrome.plwagon filled with backup tapes." -- Jim >>> Gray >>> >>> ___ >>> systemd-devel mailing list >>> systemd-devel@lists.freedesktop.org >>> https://lists.freedesktop.org/mailman/listinfo/systemd-devel >>> >> >> >> ___ >> systemd-devel mailing list >> systemd-devel@lists.freedesktop.org >> https://lists.freedesktop.org/mailman/listinfo/systemd-devel >> >> > > > -- > > Alessandro Puccetti > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Query regarding NOTIFY_SOCKET
Hi Tomasz, Thanks for pointing out the mistake. I actually missed the line "Type=notify" in the mail. I found the journalctl logs and from that I can make out the real problem is not about NOTIFY_SOCKET. It is about child process in my application *Myapp.* Below given is my Service file. *[Unit]* *Description=Sd_notify example* *[Service]* *Type=notify* *ExecStart=/etc/Myapp* *[Install]* *WantedBy=multi-user.target* And in Myapp code my application is using fork() to create a child process. Because of which notification is not working correctly. This is error log *localhost systemd[1]: sd_example.service: Got notification message from PID 1270, but reception only permitted for main PID 1106* Is there any way from which we can force sd_notify to make use of Parent PID instead of child process. My sd_notify is after the fork() call, so I doubt sd_notify is called from child process. MyApp code snippet *int count = 0;* *cpid = fork();* *if (cpid < 0)* *{* *printf("vfork failed.");* *}* *if (cpid == 0)* *{* *count++;* *if(count == 1)* * {* * ret = sd_notify(0, "READY=1");* * printf("Return value = %d \n");* * }* * }* Regards, Raghavendra H R -- Regards, Raghavendra. H. R (Raghu) On Tue, Nov 8, 2016 at 5:15 PM, Tomasz Torcz wrote: > On Tue, Nov 08, 2016 at 05:01:59PM +0530, Raghavendra. H. R wrote: > > Hi All, > > > > I'm a newbie in Systemd init system and I'm exploring sd_notify which is > > basically used for notification purpose in SystemD. > > It is written “systemd” (all lowercase). > > > I have created one unit file which is of type "notify" and in my > > application I have written sd_notify(0, "READY=1"); from which SystemD > can > > be notified that my process in totally up and running. > > > > Below given is my Service file. > > > > *[Unit]* > > *Description=Sd_notify example* > > > > *[Service]* > > *ExecStart=/etc/Myapp* > > > This is not 'unit of type notify'. This is unit of type 'simple'. > Please read "man systemd.service" and paragraph Type= and choose > correctly. > > > > Need help in understanding what value should be set in the environment > > varaible NOTIFY_SOCKET. > > But there's no much information/documentation available on NOTIFY_SOCKET. > > NOTIFY_SOCKET is filled-in by systemd and it is available when you > correctly defined unit type. If you want to check it's value, you can > user getenv() inside you program and print the value. > I think amount of documentation about NOTIFY_SOCKET is enough, if > you think there's something specific missing, let us know. > > > -- > Tomasz Torcz "Never underestimate the bandwidth of a station > xmpp: zdzich...@chrome.plwagon filled with backup tapes." -- Jim Gray > > ___ > systemd-devel mailing list > systemd-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/systemd-devel > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] Query regarding NOTIFY_SOCKET
Hi All, I'm a newbie in Systemd init system and I'm exploring sd_notify which is basically used for notification purpose in SystemD. I have created one unit file which is of type "notify" and in my application I have written sd_notify(0, "READY=1"); from which SystemD can be notified that my process in totally up and running. I getting return value of '0' from sd_notify and my service file terminates after 30 secs of default timeout. Need help in understanding what value should be set in the environment varaible NOTIFY_SOCKET. But there's no much information/documentation available on NOTIFY_SOCKET. Below given is my Service file. *[Unit]* *Description=Sd_notify example* *[Service]* *ExecStart=/etc/Myapp* *[Install]* *WantedBy=multi-user.target* In *Myapp *code I have added the sd_notify(0, "READY=1") and getting return value of 0. Kindly provide your inputs regarding NOTIFY_SOCKET. -- Regards, Raghavendra. H. R (Raghu) ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Applications using mulitple fork() in SystemD
Hi Andrei, Thanks for the quick reply. *"Most simple answer - it tries to find C in PATH and PATH in* *your login session is different from PATH systemd uses.* *"* I have all the binaries placed in a single environment file and my unit file includes that environment file. So ideally it should take all the binaries from PATH environment variable right. -- Regards, Raghavendra. H. R (Raghu) On Mon, Oct 24, 2016 at 10:43 PM, Andrei Borzenkov wrote: > 24.10.2016 20:03, Raghavendra. H. R пишет: > > Hi All, > > > > I'm a newbie and exploring Systemd init system and I have a doubt > regarding > > how multiple fork() from an application is handled in SystemD > environment. > > > > I have application of process A, which forks process B and B in turn > forks > > another process C like A -> B -> C. > > > > *My systemd service file will spawn the application and starts process A > > and I can see that only process B is forked but not process C.* > > > > Below given is my unit file. > > > > *[Unit]* > > *Description=Multiple fork* > > > > *[Service]* > > *ExecStart=/etc/A* > > > > *[Install]* > > *WantedBy=multi-user.target* > > > > > > Instead of running in a unit file, if I run my application manually all > the > > processes will spawned. > > For Eg : > > == > > cd /etc > > ./A & ---> this will cause all the 3 process to be spawned > > > > Can anyone let me know how to resolve this issue in SystemD ? > > This is outside of scope of systemd. You need to debug B why it fails to > start C. Most simple answer - it tries to find C in PATH and PATH in > your login session is different from PATH systemd uses. > > > Like *"Type=forking", *do we have any other option which helps in > achieving > > this problem statement. > > > > -- > > Regards, > > Raghavendra. H. R > > (Raghu) > > > > > > > > ___ > > systemd-devel mailing list > > systemd-devel@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/systemd-devel > > > > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] Applications using mulitple fork() in SystemD
Hi All, I'm a newbie and exploring Systemd init system and I have a doubt regarding how multiple fork() from an application is handled in SystemD environment. I have application of process A, which forks process B and B in turn forks another process C like A -> B -> C. *My systemd service file will spawn the application and starts process A and I can see that only process B is forked but not process C.* Below given is my unit file. *[Unit]* *Description=Multiple fork* *[Service]* *ExecStart=/etc/A* *[Install]* *WantedBy=multi-user.target* Instead of running in a unit file, if I run my application manually all the processes will spawned. For Eg : == cd /etc ./A & ---> this will cause all the 3 process to be spawned Can anyone let me know how to resolve this issue in SystemD ? Like *"Type=forking", *do we have any other option which helps in achieving this problem statement. -- Regards, Raghavendra. H. R (Raghu) ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Auto-start of a Service in systemd
Andrei, Your doubt is absolutely correct. Default target of the system as nothing to do with auto start of services. I checked both graphical.target & multi-user.target, surprisingly I don't see any big difference in these. Both of the files are almost same except multi-user.target have dependency *After=* with *rescue.service & rescue.target* which is restricting multi-user.target from starting. However graphical.target don't depend on rescue services, so it is active & started. And by making graphical.target as dependency in my unit file solved my problem. Hopefully if I remove the rescue services dependency from multi-user.target and add it as dependency then my service should come up without failures. Thanks for your valuable feedback. Regards, Raghavendra H R -- Regards, Raghavendra. H. R (Raghu) On Wed, Oct 5, 2016 at 4:55 PM, Andrei Borzenkov wrote: > On Wed, Oct 5, 2016 at 1:19 PM, Raghavendra. H. R > wrote: > > It's working fine now. We should give the default target of the system > for > > WantedBy= of the Install section. > > So I used graphical.target in the Install section and it fixed my issue. > > > > I doubt it was the reason. grpahical.target pulls in multi-user.target > unless you have very customized unit definitions. > > > Thanks for the information. > > > > > > > > -- > > Regards, > > > > Raghavendra. H. R > > (Raghu) > > > > On Wed, Oct 5, 2016 at 3:12 PM, Raghavendra. H. R > > wrote: > >> > >> I ran "systemctl enable test.service" but when I restart it shows only > >> that the service is only enabled but not active and running. > >> > >> Here is the status of test.service > >> > >> ? test.service - Hey Bings > >>Loaded: loaded (/lib/systemd/system/test.service; enabled) > >>Active: inactive (dead) > >> > >> > >> For WantedBy= which attribute should be given, whether it is > >> "default.target" or the default target of the system ? > >> Running systemctl get-default shows graphical.target as the default > >> target. > >> > >> -- > >> Regards, > >> > >> Raghavendra. H. R > >> (Raghu) > >> > >> On Wed, Oct 5, 2016 at 2:59 PM, Andrei Borzenkov > >> wrote: > >>> > >>> On Wed, Oct 5, 2016 at 12:23 PM, Raghavendra. H. R < > raghuh...@gmail.com> > >>> wrote: > >>> > Hi All, > >>> > > >>> > I'm a newbie in Systemd init system and I'm trying to auto boot/start > >>> > my > >>> > service in systemd. But my service gets only enabled and it never > runs > >>> > automatically. > >>> > > >>> > I modifying my unit file to depend on sysinit.target and > >>> > multi-user.target > >>> > by making use of I used After= this also didnt help. > >>> > > >>> > I would like to do something in my unit file from which systemd > starts > >>> > my > >>> > service automatically after starting it's own system related > services. > >>> > > >>> > >>> There is no such thing as "own systemd services". All services are > >>> equal (but some are more equal than others :) > >>> > >>> > Can anyone help me regarding this ? > >>> > > >>> > > >>> > My sample service > >>> > = > >>> > [Unit] > >>> > Description=Hey Bings > >>> > > >>> > [Service] > >>> > ExecStart="Run an executable" > >>> > > >>> > [Install] > >>> > WantedBy=multi-user.target or sysinit.target > >>> > > >>> > >>> sysinit.target is wrong, it should never be used for normal service. > >>> multi-user.target should work as long as it is your default target (or > >>> dependency of default target). > >>> > >>> You did run "systemctl enable your.service", did not you? What > >>> "systemctl status your.service" says? > >> > >> > > > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Auto-start of a Service in systemd
It's working fine now. We should give the default target of the system for *WantedBy= *of the Install section. So I used graphical.target in the Install section and it fixed my issue. Thanks for the information. -- Regards, Raghavendra. H. R (Raghu) On Wed, Oct 5, 2016 at 3:12 PM, Raghavendra. H. R wrote: > I ran *"systemctl enable test.service" *but when I restart it shows only > that the service is only enabled but not active and running. > > Here is the status of test.service > > *? test.service - Hey Bings* > * Loaded: loaded (/lib/systemd/system/test.service; enabled)* > * Active: inactive (dead)* > > > For *WantedBy= *which attribute should be given, whether it is > "default.target" or the default target of the system ? > Running *systemctl get-default* shows graphical.target as the default > target. > > -- > Regards, > > Raghavendra. H. R > (Raghu) > > On Wed, Oct 5, 2016 at 2:59 PM, Andrei Borzenkov > wrote: > >> On Wed, Oct 5, 2016 at 12:23 PM, Raghavendra. H. R >> wrote: >> > Hi All, >> > >> > I'm a newbie in Systemd init system and I'm trying to auto boot/start my >> > service in systemd. But my service gets only enabled and it never runs >> > automatically. >> > >> > I modifying my unit file to depend on sysinit.target and >> multi-user.target >> > by making use of I used After= this also didnt help. >> > >> > I would like to do something in my unit file from which systemd starts >> my >> > service automatically after starting it's own system related services. >> > >> >> There is no such thing as "own systemd services". All services are >> equal (but some are more equal than others :) >> >> > Can anyone help me regarding this ? >> > >> > >> > My sample service >> > = >> > [Unit] >> > Description=Hey Bings >> > >> > [Service] >> > ExecStart="Run an executable" >> > >> > [Install] >> > WantedBy=multi-user.target or sysinit.target >> > >> >> sysinit.target is wrong, it should never be used for normal service. >> multi-user.target should work as long as it is your default target (or >> dependency of default target). >> >> You did run "systemctl enable your.service", did not you? What >> "systemctl status your.service" says? >> > > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Auto-start of a Service in systemd
I ran *"systemctl enable test.service" *but when I restart it shows only that the service is only enabled but not active and running. Here is the status of test.service *? test.service - Hey Bings* * Loaded: loaded (/lib/systemd/system/test.service; enabled)* * Active: inactive (dead)* For *WantedBy= *which attribute should be given, whether it is "default.target" or the default target of the system ? Running *systemctl get-default* shows graphical.target as the default target. -- Regards, Raghavendra. H. R (Raghu) On Wed, Oct 5, 2016 at 2:59 PM, Andrei Borzenkov wrote: > On Wed, Oct 5, 2016 at 12:23 PM, Raghavendra. H. R > wrote: > > Hi All, > > > > I'm a newbie in Systemd init system and I'm trying to auto boot/start my > > service in systemd. But my service gets only enabled and it never runs > > automatically. > > > > I modifying my unit file to depend on sysinit.target and > multi-user.target > > by making use of I used After= this also didnt help. > > > > I would like to do something in my unit file from which systemd starts my > > service automatically after starting it's own system related services. > > > > There is no such thing as "own systemd services". All services are > equal (but some are more equal than others :) > > > Can anyone help me regarding this ? > > > > > > My sample service > > = > > [Unit] > > Description=Hey Bings > > > > [Service] > > ExecStart="Run an executable" > > > > [Install] > > WantedBy=multi-user.target or sysinit.target > > > > sysinit.target is wrong, it should never be used for normal service. > multi-user.target should work as long as it is your default target (or > dependency of default target). > > You did run "systemctl enable your.service", did not you? What > "systemctl status your.service" says? > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] Auto-start of a Service in systemd
Hi All, I'm a newbie in Systemd init system and I'm trying to auto boot/start my service in systemd. But my service gets only enabled and it never runs automatically. I modifying my unit file to depend on sysinit.target and multi-user.target by making use of I used *After=* this also didnt help. *I would like to do something in my unit file from which systemd starts my service automatically after starting it's own system related services. * Can anyone help me regarding this ? My sample service = [Unit] Description=Hey Bings [Service] ExecStart="Run an executable" [Install] WantedBy=multi-user.target *or* sysinit.target -- Regards, Raghavendra. H. R (Raghu) ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Is it possible to load unit files from paths other than default paths ?
Andrei, How to set SYSTEMD_UNIT_PATH in Systemd ? I checked about systemd source code in github. Please see this link https://github.com/search?q=org%3Asystemd+systemd_unit_path&type=Code Even in these source files they are doing getenv and setenv for SYSTEMD_UNIT_PATH. I dont see any conf file using which we can configure the environment variable. Regards, Raghu. -- Regards, Raghavendra. H. R (Raghu) On Mon, Sep 26, 2016 at 1:59 PM, Andrei Borzenkov wrote: > On Mon, Sep 26, 2016 at 10:59 AM, Raghavendra. H. R > wrote: > > These are instructions which I tried. > > > > mkdir -p /BingoDast > > mount -t nfs -o nolock :/tftpboot/raghu/BingoDast /BingoDast > > > > export PATH=$PATH:/BingoDast/bin > > export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/BingoDast/lib > > export SYSTEMD_UNIT_PATH=/BingoDast/units > > echo $SYSTEMD_UNIT_PATH > > /BingoDast/units > > > > systemctl start bingod.service > > Failed to start bingod.service: Unit bingod.service failed to load: No > such > > file or directory. > > > > SYSTEMD_UNIT_PATH has to be set in environment of systemd, not systemctl. > > > Other options which I tried for setting SYSTEMD_UNIT_PATH are given > below. > > > > 1. Just gave the environment variable directly on the console > > SYSTEMD_UNIT_PATH=/BingoDast/units > > > > 2. Gave the environment variable along with DefaultEnvinronment tag > > DefaultEnvironment=SYSTEMD_UNIT_PATH=/BingoDast/units > > > > > > Regards, > > Raghu > > > > > > -- > > Regards, > > > > Raghavendra. H. R > > (Raghu) > > > > On Mon, Sep 26, 2016 at 1:07 PM, Andrei Borzenkov > > wrote: > >> > >> On Mon, Sep 26, 2016 at 10:06 AM, Raghavendra. H. R < > raghuh...@gmail.com> > >> wrote: > >> > But SYTEMD_UNIT_PATH isn't working. I added my executables path for > this > >> > env > >> > variable but whatever I add isn't reflected for this variable. If I do > >> > echo > >> > >> Repeating this 100 times won't make it more clear. I already asked you > >> to paste exact commands and their output that you used to "add your > >> path for this env variable". > >> > >> > of $SYSTEMD_UNIT_PATH. Its all empty. My executables are not able to > >> > find > >> > the path and it is not running. > >> > > >> > -- > >> > Regards, > >> > > >> > Raghavendra. H. R > >> > (Raghu) > >> > > >> > On Thu, Sep 22, 2016 at 12:26 PM, Andrei Borzenkov < > arvidj...@gmail.com> > >> > wrote: > >> >> > >> >> On Thu, Sep 22, 2016 at 9:18 AM, Raghavendra. H. R > >> >> > >> >> wrote: > >> >> > Thank you for the suggestions. > >> >> > But with this suggestion i.e., generator file, I again need to > >> >> > add/modify > >> >> > some files. > >> >> > > >> >> > >> >> You need to add/modify some files to implement your service anyway. I > >> >> do not see how one more file is a problem so far. > >> >> > >> >> > All I'm looking into is I mount my binaries and unit files under > >> >> > /mnt. > >> >> > By > >> >> > setting any environment variable like SYSTEMD_UNIT_PATH, systemd > >> >> > should > >> >> > pick > >> >> > the unit files from /mnt and execute my binaries as per the > >> >> > instructions > >> >> > given in unit file. > >> >> > > >> >> > >> >> Which is exactly what it does. You just need to set variable in > >> >> environment of systemd. > >> >> > >> >> > In normal init.d systems, we have environment variables like PATH & > >> >> > LD_LIBRARY_PATH. > >> >> > No matter where I place my new executable or library, adding new > path > >> >> > into > >> >> > these environment variables is enough to execute or link the > library. > >> >> > > >> >> > Probably this kind of facility is not available in Systemd init > >> >> > systems. > >> >> > > >> >> > -- > >> >> > Regards, > >> >> > > >> >> > Raghavendra. H. R &
Re: [systemd-devel] Is it possible to load unit files from paths other than default paths ?
These are instructions which I tried. mkdir -p /BingoDast mount -t nfs -o nolock :/tftpboot/raghu/BingoDast /BingoDast export PATH=$PATH:/BingoDast/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/BingoDast/lib export SYSTEMD_UNIT_PATH=/BingoDast/units echo $SYSTEMD_UNIT_PATH /BingoDast/units systemctl start bingod.service *Failed to start bingod.service: Unit bingod.service failed to load: No such file or directory.* Other options which I tried for setting SYSTEMD_UNIT_PATH are given below. 1. Just gave the environment variable directly on the console SYSTEMD_UNIT_PATH=/BingoDast/units 2. Gave the environment variable along with DefaultEnvinronment tag DefaultEnvironment=SYSTEMD_UNIT_PATH=/BingoDast/units Regards, Raghu -- Regards, Raghavendra. H. R (Raghu) On Mon, Sep 26, 2016 at 1:07 PM, Andrei Borzenkov wrote: > On Mon, Sep 26, 2016 at 10:06 AM, Raghavendra. H. R > wrote: > > But SYTEMD_UNIT_PATH isn't working. I added my executables path for this > env > > variable but whatever I add isn't reflected for this variable. If I do > echo > > Repeating this 100 times won't make it more clear. I already asked you > to paste exact commands and their output that you used to "add your > path for this env variable". > > > of $SYSTEMD_UNIT_PATH. Its all empty. My executables are not able to find > > the path and it is not running. > > > > -- > > Regards, > > > > Raghavendra. H. R > > (Raghu) > > > > On Thu, Sep 22, 2016 at 12:26 PM, Andrei Borzenkov > > wrote: > >> > >> On Thu, Sep 22, 2016 at 9:18 AM, Raghavendra. H. R > > >> wrote: > >> > Thank you for the suggestions. > >> > But with this suggestion i.e., generator file, I again need to > >> > add/modify > >> > some files. > >> > > >> > >> You need to add/modify some files to implement your service anyway. I > >> do not see how one more file is a problem so far. > >> > >> > All I'm looking into is I mount my binaries and unit files under /mnt. > >> > By > >> > setting any environment variable like SYSTEMD_UNIT_PATH, systemd > should > >> > pick > >> > the unit files from /mnt and execute my binaries as per the > instructions > >> > given in unit file. > >> > > >> > >> Which is exactly what it does. You just need to set variable in > >> environment of systemd. > >> > >> > In normal init.d systems, we have environment variables like PATH & > >> > LD_LIBRARY_PATH. > >> > No matter where I place my new executable or library, adding new path > >> > into > >> > these environment variables is enough to execute or link the library. > >> > > >> > Probably this kind of facility is not available in Systemd init > systems. > >> > > >> > -- > >> > Regards, > >> > > >> > Raghavendra. H. R > >> > (Raghu) > >> > > >> > On Wed, Sep 21, 2016 at 10:40 PM, Andrei Borzenkov < > arvidj...@gmail.com> > >> > wrote: > >> >> > >> >> 21.09.2016 14:26, Raghavendra. H. R пишет: > >> >> > Hi, > >> >> > > >> >> > I'm newbie with systemd boot system and I need help in resolving > one > >> >> > issue. > >> >> > > >> >> > I would like to create a service under a customized path Eg:/mnt > and > >> >> > systemd should be able to pick my unit file from this. > >> >> > > >> >> > I tried by setting *Environment=SYSTEMD_UNIT_PATH=/mnt *from the > >> >> > console > >> >> > >> >> This should be set in environment of srarted systemd, which in case > of > >> >> systemwide init effectively means either you need to use some wrapper > >> >> to > >> >> set it and exec systemd or hack initrd. > >> >> > >> >> Also SYSTEMD_UNIT_PATH does not really play nicely with priorities of > >> >> unit locations (run-time vs. sysadmin vs. shipped). > >> >> > >> >> May be it is simpler to install generator that copies your unit > >> >> definition in standard location. This guarantees it is available > before > >> >> systemd starts. > >> > > >> > > > > > > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Is it possible to load unit files from paths other than default paths ?
But SYTEMD_UNIT_PATH isn't working. I added my executables path for this env variable but whatever I add isn't reflected for this variable. If I do echo of $SYSTEMD_UNIT_PATH. Its all empty. My executables are not able to find the path and it is not running. -- Regards, Raghavendra. H. R (Raghu) On Thu, Sep 22, 2016 at 12:26 PM, Andrei Borzenkov wrote: > On Thu, Sep 22, 2016 at 9:18 AM, Raghavendra. H. R > wrote: > > Thank you for the suggestions. > > But with this suggestion i.e., generator file, I again need to add/modify > > some files. > > > > You need to add/modify some files to implement your service anyway. I > do not see how one more file is a problem so far. > > > All I'm looking into is I mount my binaries and unit files under /mnt. By > > setting any environment variable like SYSTEMD_UNIT_PATH, systemd should > pick > > the unit files from /mnt and execute my binaries as per the instructions > > given in unit file. > > > > Which is exactly what it does. You just need to set variable in > environment of systemd. > > > In normal init.d systems, we have environment variables like PATH & > > LD_LIBRARY_PATH. > > No matter where I place my new executable or library, adding new path > into > > these environment variables is enough to execute or link the library. > > > > Probably this kind of facility is not available in Systemd init systems. > > > > -- > > Regards, > > > > Raghavendra. H. R > > (Raghu) > > > > On Wed, Sep 21, 2016 at 10:40 PM, Andrei Borzenkov > > wrote: > >> > >> 21.09.2016 14:26, Raghavendra. H. R пишет: > >> > Hi, > >> > > >> > I'm newbie with systemd boot system and I need help in resolving one > >> > issue. > >> > > >> > I would like to create a service under a customized path Eg:/mnt and > >> > systemd should be able to pick my unit file from this. > >> > > >> > I tried by setting *Environment=SYSTEMD_UNIT_PATH=/mnt *from the > >> > console > >> > >> This should be set in environment of srarted systemd, which in case of > >> systemwide init effectively means either you need to use some wrapper to > >> set it and exec systemd or hack initrd. > >> > >> Also SYSTEMD_UNIT_PATH does not really play nicely with priorities of > >> unit locations (run-time vs. sysadmin vs. shipped). > >> > >> May be it is simpler to install generator that copies your unit > >> definition in standard location. This guarantees it is available before > >> systemd starts. > > > > > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Is it possible to load unit files from paths other than default paths ?
I will explain you my problem statement. I want to provide a piece of executable to my third party. Folder structure of my output is something like this. /BingoDast |___ /BingoDast/bin/ ---> this contains exectuables |___ /BingoDast/lib/ > this contains required libraries. |___ /BingoDast/Units/ > this contains unit files which runs my executables Now my third party don't want anything else apart from this package. And he doesn't want to add any other files like generator files or they dont want to modify any unit files existing. Thirdparty is expecting is a commands like export PATH=$PATH:/BingoDast/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/BingoDast/lib for executables and libraries. Similar to run they need to have a environment variable path like for Eg: export SYSTEMD_UNIT_PATH=/BingoDast/Units and he should be able to start, stop the unit files available under /BingoDast/Units folder. But when I tried setting SYSTEMD_UNIT_PATH which is empty in case, value set for this is not reflecting. Why this value given to this environment variable is not working Regards. Raghu -- Regards, Raghavendra. H. R (Raghu) On Fri, Sep 23, 2016 at 12:00 PM, Kai Krakow wrote: > Am Thu, 22 Sep 2016 11:43:56 +0530 > schrieb "Raghavendra. H. R" : > > > Thank you for the suggestions. > > But with this suggestion I need to run as user something like that. > > > > In normal init.d systems, we have environment variables like PATH & > > LD_LIBRARY_PATH. > > No matter where I place my new executable or library, adding that > > path into these environment variables is enough to execute or link > > the library. > > > > Probably this kind of facility is not available in Systemd init > > systems. > > Then this is like asking how sysvinit could load files from other > locations than /etc/init.d. I don't think that is possible. To solve > this, one copies the init scripts from where they are to init.d and > then just enables them. Tip: systemd works the same. > > Adding a location where init scripts reside to PATH is just not exactly > what would work during boot. You are just exploiting and side effect > of /etc/init.d being scripts and not pure configuration. Service files > for systemd are configuration. Actually, this trick won't solve startup > dependencies as sysvinit systems only look at that directory (or the > runlevel directories where you'd symlink your scripts which is what > you'd do in systemd, too: symlink the services). > > If this is how you do it, create a generator which creates a service > files for each script in a directory. Gentoo has something > for /etc/local.d that works this way. Another way would be (if the copy > source is already systemd service files) to just copy those with the > generator. But that was already suggested. > > Here's the template to get you going: > https://gitweb.gentoo.org/proj/gentoo-systemd-integration.git/tree/system- > generators/gentoo-local-generator > > It expects /etc/local.d/*.{start,stop} bash scripts. I think it is easy > to adapt for you. > > > On Thu, Sep 22, 2016 at 12:34 AM, Kai Krakow > > wrote: > > > > > Am Wed, 21 Sep 2016 16:56:52 +0530 > > > schrieb "Raghavendra. H. R" : > > > > > > > Hi, > > > > > > > > I'm newbie with systemd boot system and I need help in resolving > > > > one issue. > > > > > > > > I would like to create a service under a customized path Eg:/mnt > > > > and systemd should be able to pick my unit file from this. > > > > > > > > I tried by setting *Environment=SYSTEMD_UNIT_PATH=/mnt *from the > > > > console but it didnt help and found the error *"Failed to start > > > > startup.service: Unit startup.service failed to load: No such > > > > file or directory."* > > > > > > > > > > > > Is it possible to achieve this ? > > > > > > Not sure if this helps you, i.e. is appropriate for your use-case... > > > > > > But if the directory happens to be a home directory and the services > > > are designed to be run as user, you could make the service files go > > > into $HOME/.config/systemd/user/ (or symlink this to your > > > mountpoint) and enable linger on the user (loginctl enable-linger > > > $USER). > > > > > > You can then manage these units as the user through "system --user > > > {start,stop,enable,...}" (only with real login sessions, not through > > >
Re: [systemd-devel] Is it possible to load unit files from paths other than default paths ?
Thank you for the suggestions. But with this suggestion I need to run as user something like that. In normal init.d systems, we have environment variables like PATH & LD_LIBRARY_PATH. No matter where I place my new executable or library, adding that path into these environment variables is enough to execute or link the library. Probably this kind of facility is not available in Systemd init systems. Regards, Raghavendra H R On Thu, Sep 22, 2016 at 12:34 AM, Kai Krakow wrote: > Am Wed, 21 Sep 2016 16:56:52 +0530 > schrieb "Raghavendra. H. R" : > > > Hi, > > > > I'm newbie with systemd boot system and I need help in resolving one > > issue. > > > > I would like to create a service under a customized path Eg:/mnt and > > systemd should be able to pick my unit file from this. > > > > I tried by setting *Environment=SYSTEMD_UNIT_PATH=/mnt *from the > > console but it didnt help and found the error *"Failed to start > > startup.service: Unit startup.service failed to load: No such file or > > directory."* > > > > > > Is it possible to achieve this ? > > Not sure if this helps you, i.e. is appropriate for your use-case... > > But if the directory happens to be a home directory and the services > are designed to be run as user, you could make the service files go > into $HOME/.config/systemd/user/ (or symlink this to your mountpoint) > and enable linger on the user (loginctl enable-linger $USER). > > You can then manage these units as the user through "system --user > {start,stop,enable,...}" (only with real login sessions, not through > sudo -iu $USER, but ssh would work). > > -- > Regards, > Kai > > Replies to list-only preferred. > > ___ > systemd-devel mailing list > systemd-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/systemd-devel > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Is it possible to load unit files from paths other than default paths ?
Thank you for the suggestions. But with this suggestion i.e., generator file, I again need to add/modify some files. All I'm looking into is I mount my binaries and unit files under /mnt. By setting any environment variable like SYSTEMD_UNIT_PATH, systemd should pick the unit files from /mnt and execute my binaries as per the instructions given in unit file. In normal init.d systems, we have environment variables like PATH & LD_LIBRARY_PATH. No matter where I place my new executable or library, adding new path into these environment variables is enough to execute or link the library. Probably this kind of facility is not available in Systemd init systems. -- Regards, Raghavendra. H. R (Raghu) On Wed, Sep 21, 2016 at 10:40 PM, Andrei Borzenkov wrote: > 21.09.2016 14:26, Raghavendra. H. R пишет: > > Hi, > > > > I'm newbie with systemd boot system and I need help in resolving one > issue. > > > > I would like to create a service under a customized path Eg:/mnt and > > systemd should be able to pick my unit file from this. > > > > I tried by setting *Environment=SYSTEMD_UNIT_PATH=/mnt *from the > > console > > This should be set in environment of srarted systemd, which in case of > systemwide init effectively means either you need to use some wrapper to > set it and exec systemd or hack initrd. > > Also SYSTEMD_UNIT_PATH does not really play nicely with priorities of > unit locations (run-time vs. sysadmin vs. shipped). > > May be it is simpler to install generator that copies your unit > definition in standard location. This guarantees it is available before > systemd starts. > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] Is it possible to load unit files from paths other than default paths ?
Hi, I'm newbie with systemd boot system and I need help in resolving one issue. I would like to create a service under a customized path Eg:/mnt and systemd should be able to pick my unit file from this. I tried by setting *Environment=SYSTEMD_UNIT_PATH=/mnt *from the console but it didnt help and found the error *"Failed to start startup.service: Unit startup.service failed to load: No such file or directory."* Is it possible to achieve this ? -- Regards, Raghavendra. H. R (Raghu) ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel