I try to deploy a tornado by myself on openshift diy cartridges but meet some problem.
I have installed python 2.7.6 and tornado 3.2, and tried to run the tornado hello world demo on it. But it always went error. In addition, I have executed the chmod 777 instruction for $OPENSHIFT_REPO_DIR/diy.
Here followings are what I did and the error logs. How can I solve this problem and start my application?
1.pre-install:
- python 2.7.6 in $OPENSHIFT_DATA_DIR
- tornado 3.2 via pip
2.tornado code
This file named start.py is the only file in $OPENSHIFT_REPO_DIR/diy.
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
application = tornado.web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
application.listen(8080)
tornado.ioloop.IOLoop.instance().start()
3.action_hooks files:
start:
nohup $OPENSHIFT_DATA_DIR/bin/python $OPENSHIFT_REPO_DIR/diy/start.py > $OPENSHIFT_DIY_LOG_DIR/tornado_server.log 2>&1 &
stop:
source $OPENSHIFT_CARTRIDGE_SDK_BASH
if [ -z "$(ps -ef | grep start.py | grep -v grep)" ]
then
client_result "Application is already stopped"
else
kill `ps -ef | grep start.py | grep -v grep | awk '{ print $2 }'`
> /dev/null 2>&1
fi
4.log
Traceback (most recent call last):
File ".../app-root/runtime/repo//diy/start.py",
line 13, in <module>
application.listen(8080)
File ".../app-root/data/lib/python2.7/site-packages/tornado/web.py",
line 1559, in listen
server.listen(port, address)
File ".../app-root/data/lib/python2.7/site-packages/tornado/tcpserver.py",
line 117, in listen
sockets = bind_sockets(port, address=address)
File ".../app-root/data/lib/python2.7/site-packages/tornado/netutil.py",
line 104, in bind_sockets
sock.bind(sockaddr)
File ".../app-root/data/lib/python2.7/socket.py",
line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 13] Permission denied