Windows7(32bit)用Firefly创建第一个示例

简介:

安装完成Firefly之后,在python script包(即Scripts文件夹)中就存在 firefly-admin的工具。

创建第一个工程


打开命令行窗口,运行如下命令:


firefly-admin.py createproject chat_rooms


这样就创建好了chat_rooms的工程,工程目录结构如下:(后补充,今天晚上无法上传图片!)


注意到chat_rooms文件夹下存在一个文件startmaster.py,它正是工程的启动模块,建立工程后可以直接启动startmaster.py进行测试。


方法是以管理员方式启动并进行CMD窗口,然后运行如下命令:


python startmaster.py


第一次运行时,出现类似于下面的运行错误:

import os,sys,affinity
  File "build\bdist.win32\egg\affinity\__init__.py", line 15, in <module>
  File "build\bdist.win32\egg\affinity\__init__.py", line 15, in <module>
ImportError: No module named win32api
ImportError: No module named win32api

估计是没有安装pywin32所致。于是,下载并运行pywin32-218.win32-py2.7.exe。再运行上面的程序即OK。出现类似如下的等待状态。


C:\Python27\Scripts\chat_rooms>python startmaster.py
2014-12-17 22:03:15+0800 [-] Log opened.
2014-12-17 22:03:15+0800 [-] DelaySite starting on 9998
2014-12-17 22:03:15+0800 [-] Starting factory <firefly.web.delayrequest.DelaySite instance at 0x02953AF8>
2014-12-17 22:03:15+0800 [-] BilateralFactory starting on 9999
2014-12-17 22:03:15+0800 [-] Starting factory <firefly.distributed.root.BilateralFactory instance at 0x0295
2014-12-17 22:03:16+0800 [-] Log opened.
2014-12-17 22:03:16+0800 [-] Starting factory <twisted.spread.pb.PBClientFactory instance at 0x02A79468>
2014-12-17 22:03:16+0800 [-] Log opened.
2014-12-17 22:03:16+0800 [-] gate start...
2014-12-17 22:03:16+0800 [-] gate pid: 2712
2014-12-17 22:03:16+0800 [-] Starting factory <twisted.spread.pb.PBClientFactory instance at 0x02A09378>
2014-12-17 22:03:16+0800 [-] net start...
2014-12-17 22:03:16+0800 [-] net pid: 10700
2014-12-17 22:03:16+0800 [BilateralBroker,0,127.0.0.1] node [gate] takeProxy ready
2014-12-17 22:03:16+0800 [BilateralBroker,1,127.0.0.1] node [net] takeProxy ready


再以管理员方式启动并进行CMD窗口,然后运行如下命令:

python clienttest.py


此时,当前窗口(上面这个CMD)处于等待状态。上面第一个CMD窗口(SERVER)出现类似如下提示信息:

2014-12-17 22:31:31+0800 [firefly.netconnect.protoc.LiberateFactory] Client 1 login in.[127.0.0.1,42321]
2014-12-17 22:31:31+0800 [LiberateProtocol,1,127.0.0.1] call method echo_1 on service[single]
2014-12-17 22:31:31+0800 [LiberateProtocol,1,127.0.0.1] call method echo_1 on service[single]
2014-12-17 22:31:31+0800 [LiberateProtocol,1,127.0.0.1] call method echo_1 on service[single]
2014-12-17 22:31:31+0800 [LiberateProtocol,1,127.0.0.1] call method echo_1 on service[single]
2014-12-17 22:31:31+0800 [LiberateProtocol,1,127.0.0.1] call method echo_1 on service[single]
2014-12-17 22:31:31+0800 [LiberateProtocol,1,127.0.0.1] call method echo_1 on service[single]
2014-12-17 22:31:31+0800 [LiberateProtocol,1,127.0.0.1] call method echo_1 on service[single]

2014-12-17 22:31:31+0800 [LiberateProtocol,1,127.0.0.1] call method echo_1 on service[single]

......

这说明客户端与服务器端通信正常。


注意:clienttest.py文件位于tool目录下。


另外,config.json是用来描述服务端整体架构的配置文件(目前我没有作任何修改),可以在文件中配置添加新的服务进程,描述各个服务进程的连接结构。以及数据库配置和memcached缓存服务配置。


根据Firefly官方文档,app包中就是用来服务器逻辑的地方,app包中的apptest.py提供了测试服务器的处理方式。

于是,再启动一个CMD窗口,运行如下命令:

python apptest.py


可是出现如下错误提示:

Traceback (most recent call last):
  File "apptest.py", line 5, in <module>
    @netserviceHandle
  File "C:\Python27\lib\site-packages\firefly-1.3.3dev_r0-py2.7.egg\firefly\server\globalobject.py", line 40, in netserviceHandle
    GlobalObject().netfactory.service.mapTarget(target)
AttributeError: 'NoneType' object has no attribute 'service'

网络搜索一下,没有发现恰当答案,先等等再说吧。反正这个拦路虎是迟早要解决掉的......


















本文转自朱先忠老师51CTO博客,原文链接:http://blog.51cto.com/zhuxianzhong/1591199 ,如需转载请自行联系原作者



相关文章
|
4天前
|
Unix 虚拟化 Windows
Windows Server 2025 中文版、英文版下载 (2025 年 3 月更新)
Windows Server 2025 中文版、英文版下载 (2025 年 3 月更新)
44 4
Windows Server 2025 中文版、英文版下载 (2025 年 3 月更新)
|
4天前
|
安全 数据安全/隐私保护 虚拟化
Windows Server 2022 中文版、英文版下载 (2025 年 3 月更新)
Windows Server 2022 中文版、英文版下载 (2025 年 3 月更新)
32 4
Windows Server 2022 中文版、英文版下载 (2025 年 3 月更新)
|
1月前
|
安全 Unix 虚拟化
Windows 7 & Windows Server 2008 R2 简体中文版下载 (2025 年 2 月更新)
Windows 7 & Windows Server 2008 R2 简体中文版下载 (2025 年 2 月更新)
61 11
Windows 7 & Windows Server 2008 R2 简体中文版下载 (2025 年 2 月更新)
|
1月前
|
Unix 虚拟化 Windows
Windows Server 2025 中文版、英文版下载 (2025 年 2 月更新)
Windows Server 2025 中文版、英文版下载 (2025 年 2 月更新)
92 7
Windows Server 2025 中文版、英文版下载 (2025 年 2 月更新)
|
1月前
|
安全 虚拟化 Windows
Windows Server 2019 中文版、英文版下载 (2025 年 2 月更新)
Windows Server 2019 中文版、英文版下载 (2025 年 2 月更新)
77 22
|
1月前
|
安全 网络安全 数据安全/隐私保护
Windows Server 2025 Active Directory 重置用户密码
密码重置是管理员日常任务之一,用户因忘记或多次输错密码导致账户锁定时需进行重置。本文介绍在Active Directory服务器上重置密码的三种方法。
101 3
|
3月前
|
安全 关系型数据库 MySQL
Windows Server 安装 MySQL 8.0 详细指南
安装 MySQL 需要谨慎,特别注意安全配置和权限管理。根据实际业务需求调整配置,确保数据库的性能和安全。
428 9
|
4月前
|
网络安全 Windows
Windows server 2012R2系统安装远程桌面服务后无法多用户同时登录是什么原因?
【11月更文挑战第15天】本文介绍了在Windows Server 2012 R2中遇到的多用户无法同时登录远程桌面的问题及其解决方法,包括许可模式限制、组策略配置问题、远程桌面服务配置错误以及网络和防火墙问题四个方面的原因分析及对应的解决方案。
290 4
|
4月前
|
监控 安全 网络安全
Windows Server管理:配置与管理技巧
Windows Server管理:配置与管理技巧
210 3
|
4月前
|
监控 安全 网络安全
使用EventLog Analyzer日志分析工具监测 Windows Server 安全威胁
Windows服务器面临多重威胁,包括勒索软件、DoS攻击、内部威胁、恶意软件感染、网络钓鱼、暴力破解、漏洞利用、Web应用攻击及配置错误等。这些威胁严重威胁服务器安全与业务连续性。EventLog Analyzer通过日志管理和威胁分析,有效检测并应对上述威胁,提升服务器安全性,确保服务稳定运行。
135 2

热门文章

最新文章