Bug 213954

Summary: net-mgmt/seafile-server Initscript only does not work when executed with service
Product: Ports & Packages Reporter: alex.theissen
Component: Individual Port(s)Assignee: Richard Gallamore <ultima>
Status: Closed Overcome By Events    
Severity: Affects Some People CC: 000.fbsd, Ultima1252
Priority: --- Keywords: needs-patch
Version: LatestFlags: Ultima1252: maintainer-feedback+
koobs: merge-quarterly?
Hardware: Any   
OS: Any   
Attachments:
Description Flags
rc.d/seafile none

Description alex.theissen 2016-10-31 16:36:08 UTC
When I try to start seafile using the service command I get the following error:
# service seafile start
failed to run "ccnet-server -t": Failed to execute child process "ccnet-server" (No such file or directory)

When executing the script directly it works:
# /usr/local/etc/rc.d/seafile start
[10/31/16 17:24:41] ../common/session.c(132): using config file /usr/local/www/haiwen/conf/ccnet.conf
Starting seafile server, please wait ...
Seafile server started

Because of this seafile does not start automatically at system boot. This is the related part in my /etc/rc.conf:
seafile_enable=YES
seahub_enable=YES
seahub_fastcgi=YES

Starting seahub with the service command does work, though.
Comment 1 Miroslav Lachman 2016-10-31 17:00:18 UTC
(In reply to alex.theissen from comment #0)

I think it is related to PATH or other env variables. 
/usr/sbin/service is using clean env:

exec env -i HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin $dir/$script $*


rc.d/seafile have defined function

prepare_env() {
export PATH=${seafile_path}/seafile/bin:$PATH
export LD_LIBRARY_PATH=${seafile_path}/seafile/lib/:${seafile_path}/seafile/lib64:${LD_LIBRARY_PATH}
}

But this function is never called.

I am not using seafile so I can't test it.
Comment 2 Ultima 2016-11-01 01:32:42 UTC
 This is actually a bug, ccnet-server binary reading the config in the old/incorrect directory. I suggest linking you're conf to the old directory as a workaround. If memory serves me correctly this was already fixed upstream, the reason updates have halted is due to server and client repos being split and still making decisions on the matter.

# ln -s /usr/local/www/haiwen/conf/ccnet.conf /usr/local/www/haiwen/ccnet/
Comment 3 Ultima 2016-11-01 01:52:45 UTC
 After taking another quick look, this bug is odd, others have messaged me about it and when diving in found missing haiwen/ccnet/ccnet.conf file will reproduced this error. After removing it just now, it is starting correctly with service... Ill have another go at it tomorrow. Maybe some sort of race condition?

 Also i'll check the env function as it is unused code.
Comment 4 Ultima 2016-11-06 14:45:33 UTC
Created attachment 176686 [details]
rc.d/seafile

Having a hard time reproducing this issue. Added env to the program start up as suggested by Miroslav Lachman. Can you please test it? Thanks.
Comment 5 alex.theissen 2016-11-11 23:29:37 UTC
Added prepare_env() as first call in seafile_start() in /usr/local/etc/rc.d/seafile. Now it is working.
Comment 6 Ultima 2016-12-13 17:20:22 UTC
(In reply to alex.theissen from comment #5)
 Have an update that I will be posting soon with this function added as suggested. There will be a new port for ccnet/seafile as the client and server has been split so hopefully it doesn't take to much time for the new ports to get into repo.
Comment 7 Mark Linimon freebsd_committer freebsd_triage 2017-07-19 11:44:39 UTC
Update Summary with new port name and assign to maintainer.
Comment 8 Richard Gallamore freebsd_committer freebsd_triage 2017-07-19 13:34:30 UTC
This should be fixed in an update several months ago. If the issue persists, please reopen.