Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am working on a project which is a mono EmailServer. I have tried adding a service to the systemd so that it starts up automatically during boot but I am having a problem.

I have created the script and added to /lib/systemd/system/emailserver.service and then run ln -s /lib/systemd/system/emailserver.service /etc/systemd/system/emailserver.service.

I have then executed systemd reload-daemon followed by systemctl start emailserver.service and then when I run ps -ef |grep -i emailserver I can then see that mono EmailServer.exe is running, all looking good so far.

However, when I reboot the server in the /var/log/messages file it then contains the following error message

Jul 16 19:41:02 dev-server systemd[1]: emailserver.service holdoff
time over, scheduling restart. Jul 16 19:41:02 dev-server systemd[1]:
emailserver.service holdoff time over, scheduling restart. Jul 16
19:41:03 dev-server systemd[1]: emailserver.service holdoff time over,
scheduling restart. Jul 16 19:41:03 dev-server systemd[1]:
emailserver.service holdoff time over, scheduling restart. Jul 16
19:41:03 dev-server systemd[1]: emailserver.service holdoff time over,
scheduling restart. Jul 16 19:41:04 dev-server systemd[1]:
emailserver.service holdoff time over, scheduling restart. Jul 16
19:41:04 dev-server systemd[1]: emailserver.service start request
repeated too quickly, refusing to start.

In my emailserver.service script I have the following

[Unit]
Description=Boardies Email Server Startup Script

[Service]
ExecStart=/home/bits/EmailServer/start.email
Restart=always

[Install]
WantedBy=multi-user.target

I'm using OpenSuse 12.1

What am I doing wrong, thanks for any help you can provide.

UPDATE I have found out what is causing the program to stop working at bootup but I am not sure how I can fix this problem. My program relies on a MySQL database and I think my program is starting up before MySQL has started, how can I make my service not load until after MySQL has started up.

share|improve this question
    
You should have a look at some examples, e.g: en.gentoo-wiki.com/wiki/Systemd or wiki.archlinux.org/index.php/Systemd/Services –  Ulrich Dangel Jul 16 '12 at 20:04
add comment

1 Answer

up vote 6 down vote accepted

Add After=mysql.service to your service file (or change it to the correct service name), e.g:

[Unit]
Description=Boardies Email Server Startup Script
After=mysql.service

[Service]
ExecStart=/home/bits/EmailServer/start.email
Restart=always

[Install]
WantedBy=multi-user.target

Please note that you don't have to put your service file into /lib/systemd/system, it is a user provided file and you should only copy it to /etc/systemd/system.

To get a list of all service files you can use systemctl list-unit-files and determine the correct name for your database service (it is probably either mysql.service or mysqld.service)

share|improve this answer
    
Thanks for your help –  Boardy Jul 16 '12 at 20:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.