LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS
User Name
Password
CentOS This forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation.

Notices


Reply
  Search this Thread
Old 09-22-2014, 02:41 PM   #1
mr_minning
LQ Newbie
 
Registered: Dec 2008
Location: Gothenburg, Sweden
Distribution: Fedora, CentOS 7, Ubuntu, Arch, Raspbian
Posts: 19

Rep: Reputation: 10
Starting EyeFi server daemonized with systemd


I got my old server upgraded (reinstalled rather) from CentOS 6.x to CentOS 7. On this server I had this EyeFi server running https://code.google.com/p/eyefiserver/ . It handles uploads from my EyeFi-card in my camera. On my old server I started this program with the included start script.
Code:
#!/bin/sh
#
# $Id$
#
# eyefiserver	initscript for eyefiserver.py
#		This file should be placed in /etc/init.d.
#
# Original Author: Mattias Holmlund
#
# Updated By: Dan Sully, pike

#
### BEGIN INIT INFO
# Provides:          	eyefiserver
# Required-Start:    	$all
# Required-Stop:     	$all
# Should-Start:      	$all
# Should-Stop:       	$all
# Default-Start:     	2 3 4 5
# Default-Stop:      	0 1 6
# Short-Description:	Startup script for the EyeFiServer
# Description:		EyeFiServer sits on port xxxx waiting for soap requests from
#			an EyeFi SD card; see http://www.eye.fi
### END INIT INFO
#

set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="EyeFiServer"
NAME=eyefiserver
DAEMON=/usr/local/bin/${NAME}.py
CFGFILE=/etc/$NAME.conf
LOGFILE=/var/log/$NAME.log
EYEFIUSER=www-data
EYEFIGROUP=www-data
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

#
#	Function that starts the daemon/service.
#
d_start() {
	touch $LOGFILE
	chown $EYEFIUSER:$EYEFIGROUP $LOGFILE
	start-stop-daemon --start   \
                --chuid $EYEFIUSER:$EYEFIGROUP \
                --pidfile $PIDFILE \
		--startas $DAEMON \
		--background \
                --make-pidfile \
                -- $CFGFILE $LOGFILE
}
#	Function that stops the daemon/service.
#
d_stop() {

	start-stop-daemon  --stop --oknodo --pidfile $PIDFILE 
	rm -rf $PIDFILE
}

#
#	Function that sends a SIGHUP to the daemon/service.
#
d_reload() {
	start-stop-daemon --stop --quiet --pidfile $PIDFILE \
		--name $NAME.py --signal 1
}

case "$1" in
  start)
	echo -n "Starting $DESC"
	d_start
	echo "."
	;;
  stop)
	echo -n "Stopping $DESC"
	d_stop
	echo "."
	;;
  restart|force-reload)
	#
	#	If the "reload" option is implemented, move the "force-reload"
	#	option to the "reload" entry above. If not, "force-reload" is
	#	just the same as "restart".
	#
	echo -n "Restarting $NAME"
	d_stop
	sleep 1
	d_start
	echo "."
	;;
  *)
	# echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0
But since CentOS 7 moved to Systemd that wont work any more. I need help to create a systemd start-script that "daemonizes" the eyefiserver program.

I tried to copy another start-script, but, as I'm sure what goes on, I can't really get it working.
Code:
[Unit]
Description=EyeFi Server

[Service]
Type=simple
User=www-data
Group=www-data
PIDFile=/var/run/eyefiserver.pid
ExecStart=/usr/local/bin/eyefiserver.py /etc/eyefiserver.conf /var/log/eyefiserver.log

[Install]
WantedBy=multi-user.target
Can anybody give me some help or pointers?
 
Old 09-25-2014, 12:47 PM   #2
mr_minning
LQ Newbie
 
Registered: Dec 2008
Location: Gothenburg, Sweden
Distribution: Fedora, CentOS 7, Ubuntu, Arch, Raspbian
Posts: 19

Original Poster
Rep: Reputation: 10
[solved]

Seems to be working now. Just renamed the file to /usr/lib/systemd/system/eyefi.service and "rebooted several times without saving my files ". And now it works... Don't know what went wrong the first time , but this config looks easier than the old "init.d-one".

Last edited by mr_minning; 09-25-2014 at 12:50 PM.
 
Old 09-26-2014, 11:17 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Moved: This thread is more suitable in CentOS subforum and has been moved accordingly to help your thread/question get the exposure it deserves.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: The Story Behind ‘init’ and ‘systemd’: Why ‘init’ Needed to be Replaced with ‘systemd’ in Linu LXer Syndicated Linux News 1 04-07-2017 11:33 PM
LXer: Is systemd as bad as boycott systemd is trying to make it? LXer Syndicated Linux News 0 09-03-2014 05:50 PM
Boot Delay 30min: systemd-analyze blame systemd-tmpfiles-setup.service BGHolmes Fedora 0 07-27-2011 09:02 AM
check and restart (if dead) a daemonized process ABL Linux - Server 4 10-23-2008 01:50 PM
"Talk" to daemonized ctorrent processes? zaubara Linux - Software 0 01-14-2008 02:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS

All times are GMT -5. The time now is 02:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration