3 ###############################################
4 # chanspyd - chanspy daemon
5 # Copyright (C) 2008 anonymous
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 ###############################################
30 if os
.path
.exists(PID
):
31 sys
.stderr
.write('chanspyd\'s already executed. If not then remove %s.\n' %PID
)
37 #f.write(str(os.getpid()))
40 sys
.stderr
.write('can\'t write pid to file\n')
43 services
.start(logfile
)
46 help = ('Usage: %s OPTIONS' %sys
.argv
[0]) +\
49 '-d --daemon run in background\n' +\
50 '-k --kill kill daemon'
54 error
= ('%s: invalid option.\n' %sys
.argv
[0]) +\
55 'Try `%s --help\' for more information.\n' %sys
.argv
[0]
56 sys
.stderr
.write(error
)
65 sys
.stderr
.write('chanspyd is not running\n')
69 os
.kill(int(pid
), signal
.SIGTERM
)
71 sys
.stderr
.write('cat\'t kill %s\n' %pid
)
74 ###############################################
75 logfile
= '/dev/stdout'
76 if len(sys
.argv
) == 2:
77 if sys
.argv
[1] == '-h' or sys
.argv
[1] == '--help':
80 elif sys
.argv
[1] == '-d' or sys
.argv
[1] == '--daemon' :
81 logfile
= 'chanspyd.log'
90 elif sys
.argv
[1] == '-k' or sys
.argv
[1] == '--kill':
95 elif len(sys
.argv
) == 1: