systemd unit for OFBiz with Oracle JDK

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

systemd unit for OFBiz with Oracle JDK

Bagas Sanjaya
Hello,

I'd like to create systemd unit for my OFBiz setup which run with JDK from Oracle.

However, I don't know how to set environment variables required (JAVA_HOME and PATH). How can I set them correctly?

I installed Oracle JDK to /opt/jdk1.8.0_201 and OFBiz to /opt/apache-ofbiz-16.11.05.

Kind regards, Bagas

--
An old man doll... just what I always wanted! - Clara

Reply | Threaded
Open this post in threaded view
|

Re: systemd unit for OFBiz with Oracle JDK

taher
Hello,

I would say this is mostly a systemd question on how to setup environment
variables, not an OFBiz specific question.

The answer is probably not simple because there are many ways. One way for
example is to use Environment= or EnvironmentFile=. Alternatively you can
do something like systemctl edit ofbiz-service and then edit the conf file.
Check [1] for more info.

[1]
https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines

On Sat, Aug 10, 2019, 2:05 PM Bagas Sanjaya <[hidden email]> wrote:

> Hello,
>
> I'd like to create systemd unit for my OFBiz setup which run with JDK from
> Oracle.
>
> However, I don't know how to set environment variables required (JAVA_HOME
> and PATH). How can I set them correctly?
>
> I installed Oracle JDK to /opt/jdk1.8.0_201 and OFBiz to
> /opt/apache-ofbiz-16.11.05.
>
> Kind regards, Bagas
>
> --
> An old man doll... just what I always wanted! - Clara
>
>
Reply | Threaded
Open this post in threaded view
|

Re: systemd unit for OFBiz with Oracle JDK

Bagas Sanjaya
Alright, so I write the following successful snippet:

[Unit]
Description=OFBiz service
Requires=nginx.service
After=nginx.service

[Service]
Type=simple
Environment="JAVA_HOME=/opt/jdk1.8.0_201"
Environment="PATH=/opt/jdk1.8.0_201/bin:/bin:/sbin:/usr/bin:/usr/sbin"
User=ofbiz
WorkingDirectory=/opt/apache-ofbiz-16.11.05
ExecStart=/opt/apache-ofbiz-16.11.05/gradlew ofbiz
ExecStop=/opt/apache-ofbiz-16.11.05/gradlew 'ofbiz --shutdown'

[Install]
WantedBy=multi-user.target

 From above snippet, I noted:
- when quoting arguments for Environment= option, anything inside quote
will be interpreted literally, so "$PATH:foo" will be just $PATH:foo.
Thus I have to hard-code PATH.
- systemd requires write out full path to the executable for ExecStart=
and ExecStop= (which is gradlew wrapper in OFBiz directory in this
case), although WorkingDirectory is set to path of OFBiz.
- since I installed JDK to /opt, JAVA_HOME is set to JDK path, in order
for OFBiz to function.

On 10/08/19 18.59, Taher Alkhateeb wrote:

> Hello,
>
> I would say this is mostly a systemd question on how to setup environment
> variables, not an OFBiz specific question.
>
> The answer is probably not simple because there are many ways. One way for
> example is to use Environment= or EnvironmentFile=. Alternatively you can
> do something like systemctl edit ofbiz-service and then edit the conf file.
> Check [1] for more info.
>
> [1]
> https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines
>
> On Sat, Aug 10, 2019, 2:05 PM Bagas Sanjaya <[hidden email]> wrote:
>
>> Hello,
>>
>> I'd like to create systemd unit for my OFBiz setup which run with JDK from
>> Oracle.
>>
>> However, I don't know how to set environment variables required (JAVA_HOME
>> and PATH). How can I set them correctly?
>>
>> I installed Oracle JDK to /opt/jdk1.8.0_201 and OFBiz to
>> /opt/apache-ofbiz-16.11.05.
>>
>> Kind regards, Bagas
>>
>> --
>> An old man doll... just what I always wanted! - Clara
>>
>>
>

--
An old man doll... just what I always wanted! - Clara
Reply | Threaded
Open this post in threaded view
|

Re: systemd unit for OFBiz with Oracle JDK

Bagas Sanjaya
Sorry if I'm still new to sysadmin world and asking such dumb question.

PS: I'm not sure whether I send this to legit-questionable email.

On 11/08/19 20.14, OFBiz wrote:

> No.  This is a system administration issue, not an OFBiz issue. Learn
> your quotes.
>
> David
>
> On 8/11/19 2:57 AM, Bagas Sanjaya wrote:
>> Alright, so I write the following successful snippet:
>>
>> [Unit]
>> Description=OFBiz service
>> Requires=nginx.service
>> After=nginx.service
>>
>> [Service]
>> Type=simple
>> Environment="JAVA_HOME=/opt/jdk1.8.0_201"
>> Environment="PATH=/opt/jdk1.8.0_201/bin:/bin:/sbin:/usr/bin:/usr/sbin"
>> User=ofbiz
>> WorkingDirectory=/opt/apache-ofbiz-16.11.05
>> ExecStart=/opt/apache-ofbiz-16.11.05/gradlew ofbiz
>> ExecStop=/opt/apache-ofbiz-16.11.05/gradlew 'ofbiz --shutdown'
>>
>> [Install]
>> WantedBy=multi-user.target
>>
>> From above snippet, I noted:
>> - when quoting arguments for Environment= option, anything inside
>> quote will be interpreted literally, so "$PATH:foo" will be just
>> $PATH:foo. Thus I have to hard-code PATH.
>> - systemd requires write out full path to the executable for
>> ExecStart= and ExecStop= (which is gradlew wrapper in OFBiz directory
>> in this case), although WorkingDirectory is set to path of OFBiz.
>> - since I installed JDK to /opt, JAVA_HOME is set to JDK path, in
>> order for OFBiz to function.
>>
>> On 10/08/19 18.59, Taher Alkhateeb wrote:
>>> Hello,
>>>
>>> I would say this is mostly a systemd question on how to setup
>>> environment
>>> variables, not an OFBiz specific question.
>>>
>>> The answer is probably not simple because there are many ways. One
>>> way for
>>> example is to use Environment= or EnvironmentFile=. Alternatively you
>>> can
>>> do something like systemctl edit ofbiz-service and then edit the conf
>>> file.
>>> Check [1] for more info.
>>>
>>> [1]
>>> https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines 
>>>
>>>
>>> On Sat, Aug 10, 2019, 2:05 PM Bagas Sanjaya <[hidden email]>
>>> wrote:
>>>
>>>> Hello,
>>>>
>>>> I'd like to create systemd unit for my OFBiz setup which run with
>>>> JDK from
>>>> Oracle.
>>>>
>>>> However, I don't know how to set environment variables required
>>>> (JAVA_HOME
>>>> and PATH). How can I set them correctly?
>>>>
>>>> I installed Oracle JDK to /opt/jdk1.8.0_201 and OFBiz to
>>>> /opt/apache-ofbiz-16.11.05.
>>>>
>>>> Kind regards, Bagas
>>>>
>>>> --
>>>> An old man doll... just what I always wanted! - Clara
>>>>
>>>>
>>>
>>

--
An old man doll... just what I always wanted! - Clara
Reply | Threaded
Open this post in threaded view
|

Re: systemd unit for OFBiz with Oracle JDK

Bagas Sanjaya
Thanks for your book suggestions sir.

On 13/08/19 01.37, OFBiz wrote:

> Bagas,
>
> Yep.  That's why I replied.  And again.  The unspoken assumption here is
> that you're running on GNU/Linux.  You are well served by schooling
> yourself on the basics of the Unix/Linux environment, especially bash. I
> can tell you here an now where you've made at least one mistake, but I'm
> not going to, because you need to learn how quoting works in
> Unix/Linux.  It is really basic stuff, stuff that is requisite to the
> job of administrating OFBiz.  Requisite to, not a part of running OFBiz.
>
> Clear advice: get and learn a book on Linux.  I used O'Reilly's "Running
> Linux" as an introductory book, in college, suitable for an exposing my
> classes to the vast resources of GNU/Linux.  If you are going to be a
> legitimate system administrator, then grab "Learning the bash Shell"
> too, also by O'Reilly.  None of this stuff is hard, yet none of it is
> possible without familiarity. Which I think is where you're at, at this
> point.  Enjoy the ride!
>
> David
>
> On 8/12/19 4:22 AM, Bagas Sanjaya wrote:
>> Sorry if I'm still new to sysadmin world and asking such dumb question.
>>
>> PS: I'm not sure whether I send this to legit-questionable email.
>>
>> On 11/08/19 20.14, OFBiz wrote:
>>> No.  This is a system administration issue, not an OFBiz issue. Learn
>>> your quotes.
>>>
>>> David
>>>
>>> On 8/11/19 2:57 AM, Bagas Sanjaya wrote:
>>>> Alright, so I write the following successful snippet:
>>>>
>>>> [Unit]
>>>> Description=OFBiz service
>>>> Requires=nginx.service
>>>> After=nginx.service
>>>>
>>>> [Service]
>>>> Type=simple
>>>> Environment="JAVA_HOME=/opt/jdk1.8.0_201"
>>>> Environment="PATH=/opt/jdk1.8.0_201/bin:/bin:/sbin:/usr/bin:/usr/sbin"
>>>> User=ofbiz
>>>> WorkingDirectory=/opt/apache-ofbiz-16.11.05
>>>> ExecStart=/opt/apache-ofbiz-16.11.05/gradlew ofbiz
>>>> ExecStop=/opt/apache-ofbiz-16.11.05/gradlew 'ofbiz --shutdown'
>>>>
>>>> [Install]
>>>> WantedBy=multi-user.target
>>>>
>>>> From above snippet, I noted:
>>>> - when quoting arguments for Environment= option, anything inside
>>>> quote will be interpreted literally, so "$PATH:foo" will be just
>>>> $PATH:foo. Thus I have to hard-code PATH.
>>>> - systemd requires write out full path to the executable for
>>>> ExecStart= and ExecStop= (which is gradlew wrapper in OFBiz
>>>> directory in this case), although WorkingDirectory is set to path of
>>>> OFBiz.
>>>> - since I installed JDK to /opt, JAVA_HOME is set to JDK path, in
>>>> order for OFBiz to function.
>>>>
>>>> On 10/08/19 18.59, Taher Alkhateeb wrote:
>>>>> Hello,
>>>>>
>>>>> I would say this is mostly a systemd question on how to setup
>>>>> environment
>>>>> variables, not an OFBiz specific question.
>>>>>
>>>>> The answer is probably not simple because there are many ways. One
>>>>> way for
>>>>> example is to use Environment= or EnvironmentFile=. Alternatively
>>>>> you can
>>>>> do something like systemctl edit ofbiz-service and then edit the
>>>>> conf file.
>>>>> Check [1] for more info.
>>>>>
>>>>> [1]
>>>>> https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines 
>>>>>
>>>>>
>>>>> On Sat, Aug 10, 2019, 2:05 PM Bagas Sanjaya <[hidden email]>
>>>>> wrote:
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I'd like to create systemd unit for my OFBiz setup which run with
>>>>>> JDK from
>>>>>> Oracle.
>>>>>>
>>>>>> However, I don't know how to set environment variables required
>>>>>> (JAVA_HOME
>>>>>> and PATH). How can I set them correctly?
>>>>>>
>>>>>> I installed Oracle JDK to /opt/jdk1.8.0_201 and OFBiz to
>>>>>> /opt/apache-ofbiz-16.11.05.
>>>>>>
>>>>>> Kind regards, Bagas
>>>>>>
>>>>>> --
>>>>>> An old man doll... just what I always wanted! - Clara
>>>>>>
>>>>>>
>>>>>
>>>>
>>

--
An old man doll... just what I always wanted! - Clara