linux您在试图运行system,linux(Ubuntu)中的systemd服务出错

我试图在Ubuntu中创建服务,但是我遇到了错误。在

我写了下面的代码-

在FileSystemWatcher.pyimport requests

import json

import logging

import sys

import os

import datetime

from watchdog.events import PatternMatchingEventHandler

class DirectoryChangedHandler(PatternMatchingEventHandler):

patterns = ["*.json","*.csv"]

logFileName = datetime.datetime.now().strftime('%Y%m%d_log.log')

script_dir = os.path.dirname(__file__) #

rel_path = "log/"+logFileName

abs_logfile_path = os.path.join(script_dir, rel_path)

appConfigFilePath = os.path.abspath('config/app_config.json')

with open(appConfigFilePath) as data_file:

config = json.load(data_file)

logging.basicConfig(filename=abs_logfile_path, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.NOTSET)

def process(self, event):

print event.src_path, event.event_type

try:

filelist = [('files', open(event.src_path, 'rb'))]

postUrl = self.config["apiBaseUrl"].encode('utf-8')+self.config["fileUplaodApiUrl"].encode('utf-8')

uploadResponse = requests.post(postUrl, files=filelist)

if uploadResponse.status_code == 200:

print "Upload Successful - ", event.src_path

else:

print "Upload Failed - ", event.src_path

except:

print "Unexpected error:", sys.exc_info()[0]

pass

def on_modified(self, event):

self.process(event)

def on_created(self, event):

self.process(event)

在工作流.py-在

^{pr2}$

和(/lib/systemd/system/FileWatcherSystemd.service)[Unit]

Description=FileChangeService

[Service]

Type=forking

WorkingDirectory= /home/ashish/Documents/FileSystemWatcher

ExecStart= /home/ashish/Documents/FileSystemWatcher/workflow.py

Restart=on-failure

[Install]

WantedBy=multi-user.target

但我有以下错误-FileWatcherSystemd.service - FileChangeService Loaded: loaded

(/lib/systemd/system/FileWatcherSystemd.service; enabled; vendor

preset: enabled) Active: inactive (dead) (Result: exit-code) since

Wed 2017-07-19 10:44:39 IST; 8min ago Process: 6552

ExecStart=/home/ashish/Documents/FileSystemWatcher/FileSystemWatcher.py

(code=exited, status=203/EXEC) Main PID: 6552 (code=exited,

status=203/EXEC)

Jul 19 10:44:39 Ashish-PC systemd[1]: FileWatcherSystemd.service: Unit

entered failed state. Jul 19 10:44:39 Ashish-PC systemd[1]:

FileWatcherSystemd.service: Failed with result 'exit-code'. Jul 19

10:44:39 Ashish-PC systemd[1]: FileWatcherSystemd.service: Service

hold-off time over, scheduling restart. Jul 19 10:44:39 Ashish-PC

systemd[1]: Stopped FileChangeService. Jul 19 10:44:39 Ashish-PC

systemd[1]: FileWatcherSystemd.service: Start request repeated too

quickly. Jul 19 10:44:39 Ashish-PC systemd[1]: Failed to start

FileChangeService.

我不知道我在FileSytemWatcher.py或FileWatcherSystemd.service中做错了什么

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值