convert init.d to systemd, how to determine which python is installed

"Jóhann B. Guðmundsson" johannbg at gmail.com
Thu Nov 3 15:17:47 UTC 2011


On 11/03/2011 02:38 PM, Adam Jackson wrote:
> On Thu, 2011-11-03 at 10:10 -0400, Kaleb S. KEITHLEY wrote:
>> HekaFS runs a daemon from init. It's a Bottle (python-based) http server.
>>
>> In order to work on, e.g. RHEL6 in addition to Fedora, the old init
>> script has:
>> ...
>> vercmd="from distutils.sysconfig import get_python_lib; print
>> get_python_lib()"
>> py_dir=$(python -c "${vercmd}")
>> exe="${py_dir}/hekafsd.py"
>> ...
>>
>> I'd kinda like to preserve that in some fashion in the new systemd
>> service file. Not to run on RHEL6 obviously, but to be future-proof
>> against the day when python2.8 or python3.x ships in F17 or later or
>> RHEL7, e.g.
> Generate the actual systemd service file at rpmbuild time.  Something
> like this maybe, if you're using the standard magic for
> %{python_sitelib}:
>
> Source1: hekafs.service.in
> ...
> sed s/@PYTHON_SITELIB@/%{python_sitelib}/ %{SOURCE1}>  $RPM_BUILD_ROOT/lib/systemd/system/hekafs.service

Just out of curiosity are there any guidelines forbidding creating a 
symbolic link to that file from /usr/sbin

So instead of having a unit file that looks like this...

[Unit]
Description=HekaFS an Clustered File System Server
Requires=glusterd.service
After=network.target glusterd.service

[Service]
Type=oneshot
ExecStart=/usr/lib/python2.7/site-packages/hekafsd.py -l 
/var/log/hekafs/hekafsd -p /run/hekafsd.pid
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

You would have a unit file like this...

[Unit]
Description=HekaFS an Clustered File System Server
Requires=glusterd.service
After=network.target glusterd.service

[Service]
Type=oneshot
ExecStart=/usr/sbin/hekafsd -l /var/log/hekafs/hekafsd -p /run/hekafsd.pid
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

And just move the link upon update/upgrade pointing to the new version?

JBG


More information about the devel mailing list