crised / electrical

Electrical M2M software to get an Electrical Bill approximation
0 stars 0 forks source link

Polish C Daemon #19

Open crised opened 10 years ago

crised commented 10 years ago

Please finish C daemon:

rnicolau commented 10 years ago

About daemonize: http://www.freedesktop.org/software/systemd/man/daemon.html Have a look at "new style daemons" section. Basically, if we use systemd to handle our program (start it at boot, restart it if it fails, etc) then we shouldn't put all that "daemonize" code.

crised commented 10 years ago

See this: http://superuser.com/a/125650/145491

crised commented 10 years ago

@rnicolau Don't add code to the program, just make a simple scrip to put it inside /etc/init.d, so it starts at boot, and we can start/stop it.

See this example: https://gist.github.com/crised/6684173

Even simpler service script in /etc/init.d:

description "iperf - TCP" author "blah"

start on runlevel [35] stop on runlevel [!35]

exec /usr/bin/iperf -s respawn

rnicolau commented 10 years ago

Yes, that simple service file is what I'm talking about, that's an Upstart script. Having your program started/stopped/restated by Upstart is what I recommended.

crised commented 10 years ago

Cool

On Tue, Sep 24, 2013 at 11:07 AM, rnicolau notifications@github.com wrote:

Yes, that simple service file is what I'm talking about, that's an Upstart script. Having your program started/stopped/restated by Upstart is what I recommended.

— Reply to this email directly or view it on GitHubhttps://github.com/crised/electrical/issues/19#issuecomment-25006674 .

rnicolau commented 10 years ago

All done. Please read the readme about how to install the service. Also database tables need to be created again for the correct type of integers and indexing key, copy and paste from readme. Important: service will run as root, so new database user must be created.

crised commented 10 years ago

Radu good, thanks. But the db must be run by a user, not root as well as this daemon. Keep up the good work On Sep 24, 2013 8:43 PM, "rnicolau" notifications@github.com wrote:

All done. Please read the readme about how to install the service. Also database tables need to be created again for the correct type of integers and indexing key, copy and paste from readme. Important: service will run as root, so new database user must be created.

— Reply to this email directly or view it on GitHubhttps://github.com/crised/electrical/issues/19#issuecomment-25051716 .

rnicolau commented 10 years ago

ok, done. You need to edit the service file to specify the correct user.